1111 workflow_dispatch :
1212
1313permissions :
14- contents : read
15- pages : write
16- id-token : write
17-
18- env :
19- FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 : true
14+ contents : write
2015
2116concurrency :
2217 group : pages
2318 cancel-in-progress : true
2419
2520jobs :
26- build :
21+ build-and-deploy :
2722 runs-on : ubuntu-latest
2823 steps :
2924 - name : Checkout
3025 uses : actions/checkout@v5
26+ with :
27+ fetch-depth : 0
3128
3229 - name : Setup Node
3330 uses : actions/setup-node@v5
@@ -41,21 +38,32 @@ jobs:
4138 - name : Build Docs Site
4239 run : node scripts/build-docs-pages.js
4340
44- - name : Setup Pages
45- uses : actions/configure-pages@v6
41+ - name : Publish To gh-pages Branch
42+ shell : bash
43+ run : |
44+ set -euo pipefail
4645
47- - name : Upload Pages Artifact
48- uses : actions/upload-pages-artifact@v4
49- with :
50- path : .site
46+ PUBLISH_DIR="${RUNNER_TEMP}/gh-pages"
47+ git fetch origin gh-pages || true
5148
52- deploy :
53- environment :
54- name : github-pages
55- url : ${{ steps.deployment.outputs.page_url }}
56- runs-on : ubuntu-latest
57- needs : build
58- steps :
59- - name : Deploy To GitHub Pages
60- id : deployment
61- uses : actions/deploy-pages@v5
49+ if git show-ref --verify --quiet refs/remotes/origin/gh-pages; then
50+ git worktree add "$PUBLISH_DIR" refs/remotes/origin/gh-pages
51+ else
52+ git worktree add -B gh-pages "$PUBLISH_DIR"
53+ fi
54+
55+ rsync -av --delete .site/ "$PUBLISH_DIR"/
56+ touch "$PUBLISH_DIR/.nojekyll"
57+
58+ cd "$PUBLISH_DIR"
59+ git config user.name "github-actions[bot]"
60+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
61+
62+ git add --all
63+ if git diff --cached --quiet; then
64+ echo "No docs changes to publish"
65+ exit 0
66+ fi
67+
68+ git commit -m "Deploy docs for ${GITHUB_SHA}"
69+ git push origin HEAD:gh-pages
0 commit comments