From: Sebastián Ramírez Date: Mon, 20 Jul 2020 15:48:43 +0000 (+0200) Subject: ⚡ Fetch artifacts only once in preview docs GitHub action X-Git-Tag: 0.60.0~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3dd16a9458c82793c815c9c04cd1bd8dd53909f9;p=thirdparty%2Ffastapi%2Ffastapi.git ⚡ Fetch artifacts only once in preview docs GitHub action --- diff --git a/.github/actions/watch-previews/app/main.py b/.github/actions/watch-previews/app/main.py index decfb339e9..3b3520599c 100644 --- a/.github/actions/watch-previews/app/main.py +++ b/.github/actions/watch-previews/app/main.py @@ -49,6 +49,12 @@ if __name__ == "__main__": owner: NamedUser = repo.owner headers = {"Authorization": f"token {settings.input_token.get_secret_value()}"} prs = list(repo.get_pulls(state="open")) + response = httpx.get( + f"{github_api}/repos/{settings.github_repository}/actions/artifacts", + headers=headers, + ) + data = response.json() + artifacts_response = ArtifactResponse.parse_obj(data) for pr in prs: logging.info("-----") logging.info(f"Processing PR #{pr.number}: {pr.title}") @@ -68,19 +74,13 @@ if __name__ == "__main__": logging.info(f"Docs preview was notified: {notified}") if not notified: artifact_name = f"docs-zip-{commit}" - response = httpx.get( - f"{github_api}/repos/{settings.github_repository}/actions/artifacts", - headers=headers, - ) - data = response.json() - artifacts_response = ArtifactResponse.parse_obj(data) use_artifact: Optional[Artifact] = None for artifact in artifacts_response.artifacts: if artifact.name == artifact_name: use_artifact = artifact break if not use_artifact: - logging.info(f"Artifact not available") + logging.info("Artifact not available") else: logging.info(f"Existing artifact: {use_artifact.name}") response = httpx.post(