File tree Expand file tree Collapse file tree 6 files changed +57
-92
lines changed Expand file tree Collapse file tree 6 files changed +57
-92
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 6
6
types :
7
7
- completed
8
8
9
+ permissions :
10
+ deployments : write
11
+ issues : write
12
+ pull-requests : write
13
+
9
14
jobs :
10
15
deploy-docs :
11
16
runs-on : ubuntu-latest
38
43
directory : ' ./site'
39
44
gitHubToken : ${{ secrets.GITHUB_TOKEN }}
40
45
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 ) }}
46
+ - name : Set up Python
47
+ uses : actions/setup-python@v5
48
+ with :
49
+ python-version : " 3.11"
50
+ - uses : actions/cache@v4
51
+ id : cache
52
+ with :
53
+ path : ${{ env.pythonLocation }}
54
+ key : ${{ runner.os }}-python-github-actions-${{ env.pythonLocation }}-${{ hashFiles('requirements-github-actions.txt') }}-v01
55
+ - name : Install GitHub Actions dependencies
56
+ if : steps.cache.outputs.cache-hit != 'true'
57
+ run : pip install -r requirements-github-actions.txt
41
58
- name : Comment Deploy
42
59
if : steps.deploy.outputs.url != ''
43
- uses : ./.github/actions/comment-docs-preview-in-pr
44
- with :
45
- token : ${{ secrets.GITHUB_TOKEN }}
46
- deploy_url : " ${{ steps.deploy.outputs.url }}"
60
+ run : python ./scripts/comment_docs_deploy_url_in_pr.py
61
+ env :
62
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
63
+ DEPLOY_URL : ${{ steps.deploy.outputs.url }}
64
+ COMMIT_SHA : ${{ github.event.workflow_run.head_sha }}
Original file line number Diff line number Diff line change
1
+ PyGithub>=2.3.0,<3.0.0
2
+ pydantic>=2.5.3,<3.0.0
3
+ pydantic-settings>=2.1.0,<3.0.0
4
+ httpx>=0.27.0,<0.28.0
Original file line number Diff line number Diff line change
1
+ import logging
2
+ import sys
3
+
4
+ from github import Github
5
+ from pydantic import SecretStr
6
+ from pydantic_settings import BaseSettings
7
+
8
+
9
+ class Settings (BaseSettings ):
10
+ github_repository : str
11
+ github_token : SecretStr
12
+ deploy_url : str
13
+ commit_sha : str
14
+
15
+
16
+ if __name__ == "__main__" :
17
+ logging .basicConfig (level = logging .INFO )
18
+ settings = Settings ()
19
+ logging .info (f"Using config: { settings .model_dump_json ()} " )
20
+ g = Github (settings .github_token .get_secret_value ())
21
+ repo = g .get_repo (settings .github_repository )
22
+ use_pr = next (
23
+ (pr for pr in repo .get_pulls () if pr .head .sha == settings .commit_sha ), None
24
+ )
25
+ if not use_pr :
26
+ logging .error (f"No PR found for hash: { settings .commit_sha } " )
27
+ sys .exit (0 )
28
+ use_pr .as_issue ().create_comment (
29
+ f"📝 Docs preview for commit { settings .commit_sha } at: { settings .deploy_url } "
30
+ )
31
+ logging .info ("Finished" )
You can’t perform that action at this time.
0 commit comments