Skip to content

Commit

Permalink
👷 Update docs-previews to handle no docs changes (#1056)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiangolo authored Aug 8, 2024
1 parent d921fb8 commit 756626e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ jobs:
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 ) }}
- name: Comment Deploy
if: steps.deploy.outputs.url != ''
run: python ./scripts/deploy_docs_status.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEPLOY_URL: ${{ steps.deploy.outputs.url }}
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
RUN_ID: ${{ github.run_id }}
IS_DONE: "true"
14 changes: 12 additions & 2 deletions scripts/deploy_docs_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Settings(BaseSettings):
deploy_url: str | None = None
commit_sha: str
run_id: int
is_done: bool = False


def main():
Expand All @@ -30,18 +31,27 @@ def main():
commits = list(use_pr.get_commits())
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}"
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:
current_commit.create_status(
state="pending",
description="Deploy Docs",
description="Deploying Docs",
context="deploy-docs",
target_url=run_url,
)
logging.info("No deploy URL available yet")
return
current_commit.create_status(
state="success",
description="Deploy Docs",
description="Docs Deployed",
context="deploy-docs",
target_url=run_url,
)
Expand Down

0 comments on commit 756626e

Please sign in to comment.