-
Notifications
You must be signed in to change notification settings - Fork 965
100 lines (87 loc) · 2.58 KB
/
github-pages.yml
File metadata and controls
100 lines (87 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Deploy to GitHub Pages
name: Deploy to GitHub Pages
on:
# Runs on pushes targeting the main branch
push:
branches: ["main"]
# Allows manual deployment from Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 10
environment: github-pages
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper git info
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Setup Pages
uses: actions/configure-pages@v5
with:
# Automatically inject basePath in Next.js config
static_site_generator: next
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.npm
node_modules
.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Install dependencies
run: npm ci
- name: Build with Next.js
run: npm run build
env:
NODE_ENV: production
# Use environment variable for GA tracking ID
NEXT_PUBLIC_GA_TRACKING_ID: ${{ vars.NEXT_PUBLIC_GA_TRACKING_ID }}
- name: Verify build output
run: |
if [ ! -d "out" ]; then
echo "Error: 'out' directory not found. Static export failed."
exit 1
fi
echo "Build successful. Generated $(find out -type f | wc -l) files."
du -sh out/
- name: Ensure .nojekyll exists in output
run: |
if [ ! -f "out/.nojekyll" ]; then
cp public/.nojekyll out/.nojekyll || touch out/.nojekyll
fi
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./out
# Deployment job
deploy:
name: Deploy
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
timeout-minutes: 10
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4