22#
33# SPDX-License-Identifier: MIT
44
5- name : Deploy pages
5+ name : Deploy pages (reusable workflow)
66
77on :
8- workflow_run :
9- workflows :
10- - " Build HTML slides"
11- - " Build HTML and PDF slides"
12- types :
13- - completed
14-
15- # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
16- permissions :
17- contents : read
18- pages : write
19- id-token : write
20-
21- # Only one deploy run at a time across all branches
22- concurrency :
23- group : pages-deploy
24- cancel-in-progress : false
8+ workflow_call :
9+ inputs :
10+ slides_artifact :
11+ required : true
12+ type : string
2513
2614jobs :
2715 deploy :
28- if : ${{ github.event.workflow_run.conclusion == 'success' }}
16+ runs-on : ubuntu-latest
2917 environment :
3018 name : github-pages
31- url : ${{ steps.deployment.outputs.page_url }}${{ github.event.workflow_run.head_branch }}
32- runs-on : ubuntu-latest
19+ url : ${{ steps.deployment.outputs.page_url }}${{ github.ref_name }}
20+ concurrency : # Only one deploy run at a time across all branches
21+ group : pages-deploy
22+ cancel-in-progress : false
3323 steps :
3424 - name : Setup Pages
3525 id : pages
@@ -38,18 +28,16 @@ jobs:
3828 - name : Download slide artifact from build
3929 uses : actions/download-artifact@v4
4030 with :
41- name : slides
31+ name : ${{ inputs.slides_artifact }}
4232 path : ./build
43- run-id : ${{ github.event.workflow_run.id }}
44- github-token : ${{ secrets.GITHUB_TOKEN }}
4533
4634 - name : Merge previous site and new build
4735 env :
4836 SITE_ZIP : site.zip
49- BRANCH : ${{ github.event.workflow_run.head_branch }}
37+ BRANCH : ${{ github.ref_name }}
5038 shell : bash
5139 run : |
52- echo "Updating pages for branch $BRANCH: "
40+ echo "Updating pages for branch $BRANCH"
5341
5442 # Download previous site
5543 wget -q "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/$SITE_ZIP" || echo "- Downloading previous site failed - starting pages from scratch"
6250 mkdir site
6351 fi
6452
65- # Check if the build included pdfs
66- if [ -d build/pdf ]; then
67- # Deploying build including pdfs
68- # We expect that we are updating html build of the same commit
69- if diff -q build/commit_sha site/$BRANCH/commit_sha >/dev/null 2>&1; then
70- # The existing build is for the same commit
71- # OK to update
72- echo "- Updating existing pages with PDF build"
73- rm -rf site/$BRANCH
74- mv build site/$BRANCH
75- else
76- # Something is wrong
77- echo "ERROR: PDF build is trying to overwrite existing, possibly newer build"
78- exit 1
79- fi
80- else
81- # Deploying build with html only
82- # If there exist a build for the same commit, we don't do anything
83- if diff -q build/commit_sha site/$BRANCH/commit_sha >/dev/null 2>&1; then
84- echo "- Not updating existing pages"
85- else
86- echo "- Updating with new HTML build"
87- rm -rf site/$BRANCH
88- mv build site/$BRANCH
89- fi
90- fi
53+ # Update current branch
54+ rm -rf site/$BRANCH
55+ mv build site/$BRANCH
9156
9257 # Add redirecting index.html at the root
9358 cat > site/index.html <<'EOF'
@@ -127,8 +92,11 @@ jobs:
12792 - name : Upload pages artifact
12893 uses : actions/upload-pages-artifact@v3
12994 with :
95+ name : github-pages-for-${{ inputs.slides_artifact }}
13096 path : ./site
13197
13298 - name : Deploy to GitHub Pages
13399 id : deployment
134100 uses : actions/deploy-pages@v4
101+ with :
102+ artifact_name : github-pages-for-${{ inputs.slides_artifact }}
0 commit comments