Skip to content

Commit ffa3c2c

Browse files
authored
Migrate to native GitHub Pages deployment (no gh-pages branch) (#499)
* Migrate to native GitHub Pages deployment (no gh-pages branch) - Replace peaceiris/actions-gh-pages@v4 with native actions/deploy-pages@v4 - Add required permissions (pages: write, id-token: write) and environment - Add concurrency group to prevent deployment conflicts - Update linkcheck.yml to download Pages artifact instead of checking out gh-pages - Enables future deletion of gh-pages branch to reclaim ~300MB repo space Closes #419 * Address Copilot review: add actions:read permission, use release assets for linkcheck - Add actions: read permission to publish.yml (needed by dawidd6/action-download-artifact) - Switch linkcheck.yml from expiring Pages artifact to permanent release asset (tar.gz) - Eliminates dependency on artifact retention window for link checking
1 parent bd88256 commit ffa3c2c

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

.github/workflows/linkcheck.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,23 @@ jobs:
1111
permissions:
1212
issues: write # required for QuantEcon link-checker
1313
steps:
14-
# Checkout the live site (html)
15-
- name: Checkout
16-
uses: actions/checkout@v6
17-
with:
18-
ref: gh-pages
14+
# Download the latest release HTML archive (permanent, not subject to artifact expiry)
15+
- name: Get latest release asset URL
16+
id: release
17+
env:
18+
GH_TOKEN: ${{ github.token }}
19+
run: |
20+
ASSET_URL=$(gh api repos/${{ github.repository }}/releases/latest \
21+
--jq '.assets[] | select(.name | endswith(".tar.gz")) | .browser_download_url')
22+
echo "asset-url=$ASSET_URL" >> $GITHUB_OUTPUT
23+
- name: Download and extract release HTML
24+
run: |
25+
mkdir -p _site
26+
curl -sL "${{ steps.release.outputs.asset-url }}" | tar -xz -C _site
1927
- name: AI-Powered Link Checker
2028
uses: QuantEcon/action-link-checker@main
2129
with:
22-
html-path: '.' # gh-pages live html
30+
html-path: '_site'
2331
fail-on-broken: 'false'
2432
silent-codes: '403,503'
2533
ai-suggestions: 'true'

.github/workflows/publish.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,24 @@ on:
33
push:
44
tags:
55
- 'publish*'
6+
7+
permissions:
8+
contents: write
9+
actions: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
617
jobs:
718
publish:
819
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
920
runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=quantecon_ubuntu2404/disk=large"
21+
environment:
22+
name: github-pages
23+
url: ${{ steps.deployment.outputs.page_url }}
1024
steps:
1125
- name: Checkout
1226
uses: actions/checkout@v6
@@ -113,12 +127,17 @@ jobs:
113127
html-manifest.json
114128
env:
115129
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116-
- name: Deploy website to gh-pages
117-
uses: peaceiris/actions-gh-pages@v4
130+
- name: Add CNAME for custom domain
131+
run: echo "python-programming.quantecon.org" > _build/html/CNAME
132+
- name: Setup Pages
133+
uses: actions/configure-pages@v5
134+
- name: Upload Pages artifact
135+
uses: actions/upload-pages-artifact@v3
118136
with:
119-
github_token: ${{ secrets.GITHUB_TOKEN }}
120-
publish_dir: _build/html/
121-
cname: python-programming.quantecon.org
137+
path: _build/html/
138+
- name: Deploy to GitHub Pages
139+
id: deployment
140+
uses: actions/deploy-pages@v4
122141
- name: Prepare lecture-python-programming.notebooks sync
123142
shell: bash -l {0}
124143
run: |

0 commit comments

Comments
 (0)