Skip to content

Commit f737cfe

Browse files
ci: add pages site deployment jobs
1 parent cb21cce commit f737cfe

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/doc_update.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
build_website:
1919
name: Build website
2020
runs-on: "ubuntu-24.04"
21+
outputs:
22+
diff_status: ${{ steps.diff-generated.outputs.diff_status }}
23+
artifact_id: ${{ steps.upload-pages-package.outputs.artifact_id }}
24+
git_tree_hash: ${{ steps.diff-generated.outputs.git_tree_hash }}
2125
steps:
2226
- uses: actions/checkout@v6
2327
- name: Setup Pages
@@ -67,13 +71,62 @@ jobs:
6771
cd "$WORKDIR"/work
6872
git diff --cached --stat
6973
git diff --cached
74+
TREE_SHA1=$(git write-tree)
75+
echo "git_tree_hash=$TREE_SHA1" >> "$GITHUB_OUTPUT"
7076
if git diff-index --quiet HEAD; then
7177
echo "diff_status=clean" >> "$GITHUB_OUTPUT"
7278
else
7379
echo "diff_status=changed" >> "$GITHUB_OUTPUT"
7480
fi
7581
- name: Upload Pages package
82+
id: upload-pages-package
7683
if: ${{ steps.diff-generated.outputs.diff_status == 'changed' }}
7784
uses: actions/upload-pages-artifact@v4
7885
with:
7986
path: ${{ steps.make-output-dir.outputs.doc_output_dir }}/work/
87+
88+
push_pages_branch:
89+
name: Update gh-pages branch
90+
needs: build_website
91+
if: $${{ needs.build_website.outputs.diff_status == 'changed' }}
92+
permissions:
93+
contents: write
94+
environment:
95+
name: pages-via-branch-push
96+
runs-on: "ubuntu-24.04"
97+
steps:
98+
- uses: actions/checkout@v6
99+
with:
100+
ref: gh-pages
101+
path: repo
102+
- uses: actions/download-artifact@v7
103+
with:
104+
artifact-ids: ${{ needs.build_website.outputs.artifact_id }}
105+
path: built
106+
- name: Extract Artifact
107+
env:
108+
TREE_SHA1: ${{ needs.build_website.outputs.git_tree_hash }}
109+
run: |
110+
[[ ! -z "$TREE_SHA1" ]] || {
111+
>&2 echo "did not get valid sha1 hash for expected git tree from builder job"
112+
exit 1
113+
}
114+
tar -tf built/artifact.tar
115+
rm --one-file-system -rv -- $(git ls-tree --name-only HEAD)
116+
ls -R
117+
118+
publish_pages:
119+
name: Direct publish pages
120+
needs: build_website
121+
if: $${{ false && needs.build_website.outputs.diff_status == 'changed' }}
122+
permissions:
123+
pages: write
124+
id-token: write
125+
environment:
126+
name: github-pages
127+
url: ${{ steps.deployment.outputs.page_url }}
128+
runs-on: "ubuntu-24.04"
129+
steps:
130+
- name: Deploy to GitHub Pages
131+
id: deployment
132+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)