Skip to content

Commit 2fc92d3

Browse files
mike-thompson-day8Mike Thompson
andauthored
Deploy docs via Pages artifact instead of gh-pages branch (#832)
The current docs workflow commits the entire built MkDocs site to the gh-pages branch on every push to master. Over time this has accumulated ~100 MB of generated artifacts (js/docs.js, klipse_plugin.js, etc.) in the gh-pages branch, which every git clone has to download. Switch to the artifact-based actions/deploy-pages flow so the site is served from an ephemeral workflow artifact and nothing is committed to git. Once the new deployment is verified the gh-pages branch can be deleted, reducing clone size from ~100 MB to ~5 MB. Refs #831 Co-authored-by: Mike Thompson <mike.thompson+github@day8.como.au>
1 parent e150bb5 commit 2fc92d3

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

.github/workflows/docs-workflow.yml

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,25 @@
44
#
55
# More about the build process are documented at
66
# https://github.com/day8/re-frame/blob/feature/mkdocs/docs/developer-notes.md
7+
#
8+
# PREREQUISITE: the repository's Pages source must be set to "GitHub Actions"
9+
# (Settings -> Pages -> Build and deployment -> Source). If it is still set
10+
# to "Deploy from a branch" then the deploy-pages step in the github-pages
11+
# job below will fail and https://day8.github.io/re-frame/ will continue to
12+
# serve the last commit on the (now-unused) gh-pages branch until the
13+
# setting is corrected.
714

815
name: docs
916
on:
1017
push:
1118
branches: 'master'
1219

20+
# Allow only one concurrent deployment, but do not cancel in-progress runs
21+
# so that an in-flight Pages deployment can complete before the next starts.
22+
concurrency:
23+
group: "pages"
24+
cancel-in-progress: false
25+
1326
jobs:
1427
re-frame-docs-app:
1528
name: Re-frame Docs App
@@ -103,34 +116,26 @@ jobs:
103116
name: GitHub Pages
104117
needs: mkdocs
105118
runs-on: ubuntu-24.04
119+
permissions:
120+
pages: write
121+
id-token: write
122+
environment:
123+
name: github-pages
124+
url: ${{ steps.deployment.outputs.page_url }}
106125
steps:
107-
- name: Checkout GitHub Pages Branch
108-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
109-
with:
110-
ref: "gh-pages"
111-
path: "gh-pages"
112-
113126
- name: Download MkDocs Artifact
114127
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
115128
with:
116129
name: mkdocs
117130

118131
- name: Extract MkDocs Artifact
119-
run: |
120-
tar zxf mkdocs.tar.gz
121-
rm -rf gh-pages/*
122-
cp -Rv site/* gh-pages/
132+
run: tar zxf mkdocs.tar.gz
123133

124-
- name: Commit
125-
working-directory: ./gh-pages
126-
run: |
127-
git config --local user.email "action@github.com"
128-
git config --local user.name "GitHub Action"
129-
git add -A
130-
git commit -m "Update docs"
134+
- name: Upload Pages Artifact
135+
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
136+
with:
137+
path: site/
131138

132-
- name: Push
133-
working-directory: ./gh-pages
134-
run: |
135-
REMOTE="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
136-
git push "${REMOTE}" HEAD:gh-pages
139+
- name: Deploy to GitHub Pages
140+
id: deployment
141+
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0

0 commit comments

Comments
 (0)