Skip to content

Commit f54194e

Browse files
committed
Add GitHub Pages deploy workflow
- Trigger on push to main and manual dispatch - Use Node 20, install deps, compute base path - Build and upload dist, then deploy with concurrency control
1 parent 115ba1c commit f54194e

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

.github/workflows/deploy-pages.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Deploy the site to GitHub Pages.
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: github-pages
16+
cancel-in-progress: true
17+
18+
jobs:
19+
deploy:
20+
name: Deploy.
21+
runs-on: ubuntu-latest
22+
environment:
23+
name: github-pages
24+
url: ${{ steps.deployment.outputs.page_url }}
25+
steps:
26+
- name: Check out the repository.
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Node.js.
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 20
33+
34+
- name: Configure GitHub Pages.
35+
uses: actions/configure-pages@v5
36+
37+
- name: Install dependencies.
38+
run: npm install --no-audit --no-fund
39+
40+
- name: Determine the base path.
41+
id: base
42+
run: |
43+
if [ "${{ github.event.repository.name }}" = "${{ github.repository_owner }}.github.io" ]; then
44+
echo "base=/" >> "$GITHUB_OUTPUT"
45+
else
46+
echo "base=/${{ github.event.repository.name }}/" >> "$GITHUB_OUTPUT"
47+
fi
48+
49+
- name: Build the site.
50+
env:
51+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY || '' }}
52+
run: npm run build -- --base="${{ steps.base.outputs.base }}"
53+
54+
- name: Upload the Pages artifact.
55+
uses: actions/upload-pages-artifact@v3
56+
with:
57+
path: dist
58+
59+
- name: Deploy to GitHub Pages.
60+
id: deployment
61+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)