Skip to content

Commit efada41

Browse files
vishrclaude
andcommitted
ci: deploy via official GitHub Pages Actions flow (least-privilege)
Switch from peaceiris/actions-gh-pages (gh-pages branch, contents: write) to the official actions/upload-pages-artifact + actions/deploy-pages flow, so the deploy token gets `contents: read` (no write access to repo source) plus `pages: write` / `id-token: write`. NOTE: requires the repo Pages "Source" to be set to "GitHub Actions" (build_type=workflow). Custom domain (echo.labstack.com) is preserved via site/public/CNAME in the uploaded artifact. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1c2a9c8 commit efada41

1 file changed

Lines changed: 30 additions & 21 deletions

File tree

.github/workflows/deploy.yaml

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,22 @@ on:
1111
# Allow manual runs from the Actions tab.
1212
workflow_dispatch:
1313

14+
# Least privilege for the official GitHub Pages deployment: the token only needs
15+
# to publish Pages — no write access to repository source.
16+
permissions:
17+
contents: read
18+
pages: write
19+
id-token: write
20+
21+
# One deployment at a time; never cancel an in-progress one.
22+
concurrency:
23+
group: pages
24+
cancel-in-progress: false
25+
1426
jobs:
15-
deploy:
16-
name: Deploy to GitHub Pages
27+
build:
28+
name: Build
1729
runs-on: ubuntu-latest
18-
# Least privilege: the build only needs to push the gh-pages branch. Limits
19-
# blast radius if a build-time dependency is ever compromised.
20-
permissions:
21-
contents: write
2230
steps:
2331
- uses: actions/checkout@v5
2432
- uses: actions/setup-node@v6
@@ -33,25 +41,26 @@ jobs:
3341
- name: Install dependencies
3442
run: npm ci --ignore-scripts
3543
working-directory: site
36-
- name: Build website
44+
- name: Build site
3745
run: npm run build
3846
working-directory: site
3947
env:
4048
# Lifts the GitHub API rate limit for build-time stats fetches.
4149
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4250

43-
# Popular action to deploy to GitHub Pages:
44-
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
45-
- name: Deploy to GitHub Pages
46-
uses: peaceiris/actions-gh-pages@v4
51+
- name: Upload Pages artifact
52+
uses: actions/upload-pages-artifact@v3
4753
with:
48-
github_token: ${{ secrets.GITHUB_TOKEN }}
49-
# Build output to publish to the `gh-pages` branch:
50-
publish_dir: ./site/dist
51-
# The following lines assign commit authorship to the official
52-
# GH-Actions bot for deploys to `gh-pages` branch:
53-
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
54-
# The GH actions bot is used by default if you didn't specify the two fields.
55-
# You can swap them out with your own user credentials.
56-
user_name: github-actions[bot]
57-
user_email: 41898282+github-actions[bot]@users.noreply.github.com
54+
path: site/dist
55+
56+
deploy:
57+
name: 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

0 commit comments

Comments
 (0)