1- name : Deploy Astro site to Pages
1+ name : Build and publish gh-pages
22
33on :
44 push :
55 branches : ['main']
66 workflow_dispatch :
77
88permissions :
9- contents : read
10- pages : write
11- id-token : write
9+ contents : write
1210
1311concurrency :
14- group : pages
12+ group : gh- pages-publish
1513 cancel-in-progress : true
1614
1715jobs :
18- build :
16+ build-and-publish :
1917 runs-on : ubuntu-latest
20- defaults :
21- run :
22- working-directory : website
2318 steps :
24- - name : Checkout
19+ - name : Checkout source
2520 uses : actions/checkout@v4
2621 - name : Setup pnpm
2722 uses : pnpm/action-setup@v4
@@ -34,24 +29,26 @@ jobs:
3429 node-version : ' 22.16.0'
3530 cache : pnpm
3631 cache-dependency-path : website/pnpm-lock.yaml
37- - name : Setup Pages
38- uses : actions/configure-pages@v5
3932 - name : Install dependencies
33+ working-directory : website
4034 run : pnpm install --frozen-lockfile
4135 - name : Build site
36+ working-directory : website
4237 run : pnpm run build
43- - name : Upload artifact
44- uses : actions/upload-pages-artifact@v3
45- with :
46- path : website/dist
47-
48- deploy :
49- needs : build
50- runs-on : ubuntu-latest
51- environment :
52- name : github-pages
53- url : ${{ steps.deployment.outputs.page_url }}
54- steps :
55- - name : Deploy to GitHub Pages
56- id : deployment
57- uses : actions/deploy-pages@v4
38+ - name : Prepare static branch
39+ run : |
40+ touch website/dist/.nojekyll
41+ git config user.name "github-actions[bot]"
42+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
43+ git fetch origin gh-pages || true
44+ git worktree add --detach /tmp/gh-pages origin/gh-pages
45+ find /tmp/gh-pages -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
46+ cp -R website/dist/. /tmp/gh-pages/
47+ cd /tmp/gh-pages
48+ git add -A
49+ if git diff --cached --quiet; then
50+ echo "No deployment changes."
51+ else
52+ git commit -m "deploy: ${GITHUB_SHA}"
53+ git push origin HEAD:gh-pages
54+ fi
0 commit comments