👷 Update docs-previews to handle no docs changes (#1056)
This commit is contained in:
parent
d921fb8a3e
commit
756626ef5b
2
.github/workflows/deploy-docs.yml
vendored
2
.github/workflows/deploy-docs.yml
vendored
@ -64,10 +64,10 @@ jobs:
|
|||||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||||
branch: ${{ ( github.event.workflow_run.head_repository.full_name == github.repository && github.event.workflow_run.head_branch == 'main' && 'main' ) || ( github.event.workflow_run.head_sha ) }}
|
branch: ${{ ( github.event.workflow_run.head_repository.full_name == github.repository && github.event.workflow_run.head_branch == 'main' && 'main' ) || ( github.event.workflow_run.head_sha ) }}
|
||||||
- name: Comment Deploy
|
- name: Comment Deploy
|
||||||
if: steps.deploy.outputs.url != ''
|
|
||||||
run: python ./scripts/deploy_docs_status.py
|
run: python ./scripts/deploy_docs_status.py
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
DEPLOY_URL: ${{ steps.deploy.outputs.url }}
|
DEPLOY_URL: ${{ steps.deploy.outputs.url }}
|
||||||
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
|
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
|
||||||
RUN_ID: ${{ github.run_id }}
|
RUN_ID: ${{ github.run_id }}
|
||||||
|
IS_DONE: "true"
|
||||||
|
@ -12,6 +12,7 @@ class Settings(BaseSettings):
|
|||||||
deploy_url: str | None = None
|
deploy_url: str | None = None
|
||||||
commit_sha: str
|
commit_sha: str
|
||||||
run_id: int
|
run_id: int
|
||||||
|
is_done: bool = False
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -30,10 +31,19 @@ def main():
|
|||||||
commits = list(use_pr.get_commits())
|
commits = list(use_pr.get_commits())
|
||||||
current_commit = [c for c in commits if c.sha == settings.commit_sha][0]
|
current_commit = [c for c in commits if c.sha == settings.commit_sha][0]
|
||||||
run_url = f"https://github.com/{settings.github_repository}/actions/runs/{settings.run_id}"
|
run_url = f"https://github.com/{settings.github_repository}/actions/runs/{settings.run_id}"
|
||||||
|
if settings.is_done and not settings.deploy_url:
|
||||||
|
current_commit.create_status(
|
||||||
|
state="success",
|
||||||
|
description="No Docs Changes",
|
||||||
|
context="deploy-docs",
|
||||||
|
target_url=run_url,
|
||||||
|
)
|
||||||
|
logging.info("No docs changes found")
|
||||||
|
return
|
||||||
if not settings.deploy_url:
|
if not settings.deploy_url:
|
||||||
current_commit.create_status(
|
current_commit.create_status(
|
||||||
state="pending",
|
state="pending",
|
||||||
description="Deploy Docs",
|
description="Deploying Docs",
|
||||||
context="deploy-docs",
|
context="deploy-docs",
|
||||||
target_url=run_url,
|
target_url=run_url,
|
||||||
)
|
)
|
||||||
@ -41,7 +51,7 @@ def main():
|
|||||||
return
|
return
|
||||||
current_commit.create_status(
|
current_commit.create_status(
|
||||||
state="success",
|
state="success",
|
||||||
description="Deploy Docs",
|
description="Docs Deployed",
|
||||||
context="deploy-docs",
|
context="deploy-docs",
|
||||||
target_url=run_url,
|
target_url=run_url,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user