Skip to content

Commit f75b216

Browse files
committed
fix(ci): publish built site to gh-pages branch for legacy Pages source
The github-pages environment restricts deploys to the gh-pages branch and Pages uses the legacy branch source, so deploy by building site/ and force-pushing it to gh-pages (served at aw.isainative.dev) instead of the Actions Pages deployment.
1 parent 473ebb8 commit f75b216

1 file changed

Lines changed: 21 additions & 31 deletions

File tree

.github/workflows/deploy-pages.yml

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: Deploy book to GitHub Pages
22

3-
# Builds the static site from content/ with site/generate.py and publishes site/
4-
# to GitHub Pages. The committed images (cover, og-image, icons) are shipped as-is;
5-
# generate.py refreshes the HTML, sitemap, robots, manifest and llms files.
3+
# Builds the static site from content/ with site/generate.py and publishes it to the
4+
# gh-pages branch, which GitHub Pages serves (legacy branch source) at the custom
5+
# domain aw.isainative.dev. The committed images (cover, og-image, icons) ship as-is.
66

77
on:
88
push:
@@ -15,19 +15,16 @@ on:
1515
- ".github/workflows/deploy-pages.yml"
1616
workflow_dispatch:
1717

18-
# Least-privilege token; Pages deployment needs pages:write + id-token:write.
18+
# Only needs to push the built site to the gh-pages branch.
1919
permissions:
20-
contents: read
21-
pages: write
22-
id-token: write
20+
contents: write
2321

24-
# Allow one concurrent deployment; let in-progress production deploys finish.
2522
concurrency:
26-
group: pages
27-
cancel-in-progress: false
23+
group: deploy-gh-pages
24+
cancel-in-progress: true
2825

2926
jobs:
30-
build:
27+
deploy:
3128
runs-on: ubuntu-latest
3229
steps:
3330
- name: Checkout
@@ -44,23 +41,16 @@ jobs:
4441
python -m pip install pyyaml
4542
python site/generate.py
4643
47-
- name: Configure Pages
48-
uses: actions/configure-pages@v5
49-
with:
50-
enablement: true
51-
52-
- name: Upload site artifact
53-
uses: actions/upload-pages-artifact@v3
54-
with:
55-
path: site
56-
57-
deploy:
58-
needs: build
59-
runs-on: ubuntu-latest
60-
environment:
61-
name: github-pages
62-
url: ${{ steps.deployment.outputs.page_url }}
63-
steps:
64-
- name: Deploy to GitHub Pages
65-
id: deployment
66-
uses: actions/deploy-pages@v4
44+
- name: Publish site/ to gh-pages
45+
run: |
46+
cd site
47+
rm -rf __pycache__
48+
touch .nojekyll
49+
git init -q -b gh-pages
50+
git config user.name "github-actions[bot]"
51+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
52+
git add -A
53+
git commit -q -m "Deploy ${GITHUB_SHA} from ${GITHUB_REF_NAME}"
54+
git push -q --force "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" gh-pages
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)