1+ name : ChipFlow Libraray Github Pages
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ pull_request :
8+ types : [opened, synchronize, reopened, closed]
9+ branches :
10+ - main
11+ permissions :
12+ contents : read
13+ pages : write
14+ id-token : write
15+
16+ # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
17+ # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
18+ concurrency :
19+ group : " pages"
20+ cancel-in-progress : false
21+
22+ jobs :
23+ build_and_deploy_docs :
24+ runs-on : ubuntu-latest
25+ name : Build and Deploy Docs
26+ env :
27+ PR_PATH : pull/${{github.event.number}}
28+ steps :
29+ - name : Delete old doc PR comment
30+ if : ${{ github.event_name == 'pull_request' }}
31+ 32+ with :
33+ github-token : ${{ secrets.GITHUB_TOKEN }}
34+ repository : ${{ github.repository }}
35+ number : ${{ github.event.number }}
36+ id : deploy-preview
37+ delete : true
38+
39+ - name : Comment on PR
40+ if : ${{ github.event_name == 'pull_request' }}
41+ 42+ with :
43+ github-token : ${{ secrets.GITHUB_TOKEN }}
44+ repository : ${{ github.repository }}
45+ number : ${{ github.event.number }}
46+ id : deploy-preview
47+ message : " Starting deployment of preview ⏳..."
48+ recreate : true
49+
50+ - name : Get Site URL
51+ env :
52+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
53+ run : |
54+ url=$(gh api "repos/$GITHUB_REPOSITORY/pages" --jq '.html_url' | sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/')
55+ echo "DOMAIN=$url" >> $GITHUB_ENV
56+
57+ - name : Set production base URL
58+ if : ${{ github.ref == 'refs/heads/main' }}
59+ run : echo "BASE_URL=https://${{ env.DOMAIN }}/" >> $GITHUB_ENV
60+
61+ - name : Set base URL for preview if PR
62+ if : ${{ github.event_name == 'pull_request' }}
63+ run : echo "BASE_URL=https://${{ env.DOMAIN }}/${{ env.PR_PATH}}/" >> $GITHUB_ENV
64+
65+ - uses : actions/checkout@v2
66+ with :
67+ submodules : true
68+
69+ - uses : actions/checkout@v4
70+ - name : Setup PDM
71+ uses : pdm-project/setup-pdm@v4
72+ with :
73+ python-version : 3.12
74+ cache : true
75+
76+ - name : Install dependencies
77+ run : pdm install
78+
79+ - name : Build docs
80+ run : pdm docs
81+
82+ - name : Setup Pages
83+ uses : actions/configure-pages@v5
84+
85+ - name : Upload artifacts
86+ uses : actions/upload-artifact@v3
87+ with :
88+ name : html-docs
89+ path : docs/_build
90+
91+ - name : Deploy if this is the `main` branch
92+ uses : peaceiris/actions-gh-pages@v3
93+ if : ${{ github.ref == 'refs/heads/main' }}
94+ with :
95+ github_token : ${{ secrets.GITHUB_TOKEN }}
96+ publish_dir : site
97+ cname : ${{ env.DOMAIN }}
98+
99+ - name : Deploy to PR preview
100+ if : ${{ github.event_name == 'pull_request' }}
101+ uses : peaceiris/actions-gh-pages@v3
102+ with :
103+ github_token : ${{ secrets.GITHUB_TOKEN }}
104+ publish_dir : site
105+ destination_dir : ${{ env.PR_PATH }}
106+
107+ - name : Update comment
108+ if : ${{ github.event_name == 'pull_request' }}
109+ 110+ with :
111+ github-token : ${{ secrets.GITHUB_TOKEN }}
112+ repository : ${{ github.repository }}
113+ number : ${{ github.event.number }}
114+ id : deploy-preview
115+ message : " A preview of ${{ github.event.after }} is uploaded and can be seen here:\n\n ✨ ${{ env.BASE_URL }} ✨\n\n Changes may take a few minutes to propagate. Since this is a preview of production, content with `draft: true` will not be rendered. The source is here: https://github.com/${{ github.repository }}/tree/gh-pages/${{ env.PR_PATH }}/"
116+ recreate : true
0 commit comments