mirror of
https://github.com/rjNemo/fastapi
synced 2026-06-06 02:26:46 +00:00
⚡ Fetch artifacts only once in preview docs GitHub action
This commit is contained in:
parent
62c23ab5fa
commit
3dd16a9458
1 changed files with 7 additions and 7 deletions
14
.github/actions/watch-previews/app/main.py
vendored
14
.github/actions/watch-previews/app/main.py
vendored
|
|
@ -49,6 +49,12 @@ if __name__ == "__main__":
|
||||||
owner: NamedUser = repo.owner
|
owner: NamedUser = repo.owner
|
||||||
headers = {"Authorization": f"token {settings.input_token.get_secret_value()}"}
|
headers = {"Authorization": f"token {settings.input_token.get_secret_value()}"}
|
||||||
prs = list(repo.get_pulls(state="open"))
|
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:
|
for pr in prs:
|
||||||
logging.info("-----")
|
logging.info("-----")
|
||||||
logging.info(f"Processing PR #{pr.number}: {pr.title}")
|
logging.info(f"Processing PR #{pr.number}: {pr.title}")
|
||||||
|
|
@ -68,19 +74,13 @@ if __name__ == "__main__":
|
||||||
logging.info(f"Docs preview was notified: {notified}")
|
logging.info(f"Docs preview was notified: {notified}")
|
||||||
if not notified:
|
if not notified:
|
||||||
artifact_name = f"docs-zip-{commit}"
|
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
|
use_artifact: Optional[Artifact] = None
|
||||||
for artifact in artifacts_response.artifacts:
|
for artifact in artifacts_response.artifacts:
|
||||||
if artifact.name == artifact_name:
|
if artifact.name == artifact_name:
|
||||||
use_artifact = artifact
|
use_artifact = artifact
|
||||||
break
|
break
|
||||||
if not use_artifact:
|
if not use_artifact:
|
||||||
logging.info(f"Artifact not available")
|
logging.info("Artifact not available")
|
||||||
else:
|
else:
|
||||||
logging.info(f"Existing artifact: {use_artifact.name}")
|
logging.info(f"Existing artifact: {use_artifact.name}")
|
||||||
response = httpx.post(
|
response = httpx.post(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue