Skip to content

Commit 3dd16a9

Browse files
authored
⚡ Fetch artifacts only once in preview docs GitHub action
1 parent 62c23ab commit 3dd16a9

File tree

1 file changed

+7
-7
lines changed
  • .github/actions/watch-previews/app

1 file changed

+7
-7
lines changed

.github/actions/watch-previews/app/main.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ def get_message(commit: str) -> str:
4949
owner: NamedUser = repo.owner
5050
headers = {"Authorization": f"token {settings.input_token.get_secret_value()}"}
5151
prs = list(repo.get_pulls(state="open"))
52+
response = httpx.get(
53+
f"{github_api}/repos/{settings.github_repository}/actions/artifacts",
54+
headers=headers,
55+
)
56+
data = response.json()
57+
artifacts_response = ArtifactResponse.parse_obj(data)
5258
for pr in prs:
5359
logging.info("-----")
5460
logging.info(f"Processing PR #{pr.number}: {pr.title}")
@@ -68,19 +74,13 @@ def get_message(commit: str) -> str:
6874
logging.info(f"Docs preview was notified: {notified}")
6975
if not notified:
7076
artifact_name = f"docs-zip-{commit}"
71-
response = httpx.get(
72-
f"{github_api}/repos/{settings.github_repository}/actions/artifacts",
73-
headers=headers,
74-
)
75-
data = response.json()
76-
artifacts_response = ArtifactResponse.parse_obj(data)
7777
use_artifact: Optional[Artifact] = None
7878
for artifact in artifacts_response.artifacts:
7979
if artifact.name == artifact_name:
8080
use_artifact = artifact
8181
break
8282
if not use_artifact:
83-
logging.info(f"Artifact not available")
83+
logging.info("Artifact not available")
8484
else:
8585
logging.info(f"Existing artifact: {use_artifact.name}")
8686
response = httpx.post(

0 commit comments

Comments
 (0)