Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .github/actions/comment-docs-preview-in-pr/Dockerfile

This file was deleted.

13 changes: 0 additions & 13 deletions .github/actions/comment-docs-preview-in-pr/action.yml

This file was deleted.

68 changes: 0 additions & 68 deletions .github/actions/comment-docs-preview-in-pr/app/main.py

This file was deleted.

26 changes: 22 additions & 4 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
types:
- completed

permissions:
deployments: write
issues: write
pull-requests: write

jobs:
deploy-docs:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -38,9 +43,22 @@ jobs:
directory: './site'
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: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: actions/cache@v4
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-github-actions-${{ env.pythonLocation }}-${{ hashFiles('requirements-github-actions.txt') }}-v01
- name: Install GitHub Actions dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-github-actions.txt
- name: Comment Deploy
if: steps.deploy.outputs.url != ''
uses: ./.github/actions/comment-docs-preview-in-pr
with:
token: ${{ secrets.GITHUB_TOKEN }}
deploy_url: "${{ steps.deploy.outputs.url }}"
run: python ./scripts/comment_docs_deploy_url_in_pr.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEPLOY_URL: ${{ steps.deploy.outputs.url }}
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
4 changes: 4 additions & 0 deletions requirements-github-actions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PyGithub>=2.3.0,<3.0.0
pydantic>=2.5.3,<3.0.0
pydantic-settings>=2.1.0,<3.0.0
httpx>=0.27.0,<0.28.0
31 changes: 31 additions & 0 deletions scripts/comment_docs_deploy_url_in_pr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import logging
import sys

from github import Github
from pydantic import SecretStr
from pydantic_settings import BaseSettings


class Settings(BaseSettings):
github_repository: str
github_token: SecretStr
deploy_url: str
commit_sha: str


if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
settings = Settings()
logging.info(f"Using config: {settings.model_dump_json()}")
g = Github(settings.github_token.get_secret_value())
repo = g.get_repo(settings.github_repository)
use_pr = next(
(pr for pr in repo.get_pulls() if pr.head.sha == settings.commit_sha), None
)
if not use_pr:
logging.error(f"No PR found for hash: {settings.commit_sha}")
sys.exit(0)
use_pr.as_issue().create_comment(
f"📝 Docs preview for commit {settings.commit_sha} at: {settings.deploy_url}"
)
logging.info("Finished")