1
- name : 🚀 Deploy Next.js to GitHub Pages
1
+ name : 🚀 Deploy Static Next.js to GitHub Pages
2
2
3
3
on :
4
4
push :
@@ -16,7 +16,7 @@ concurrency:
16
16
17
17
jobs :
18
18
build :
19
- name : 🛠️ Build Next.js
19
+ name : 🏗 Build Static Next.js
20
20
runs-on : ubuntu-latest
21
21
steps :
22
22
- name : 🔍 Checkout repository
39
39
echo "runner=npx --no-install" >> $GITHUB_ENV
40
40
fi
41
41
42
- # ✅ Explicitly Install pnpm before setting up Node.js
43
42
- name : 📦 Install pnpm if needed
44
43
if : env.manager == 'pnpm'
45
44
run : npm install -g pnpm
@@ -56,10 +55,26 @@ jobs:
56
55
echo "npm $(npm -v)"
57
56
${{ env.manager }} --version
58
57
59
- - name : 🌐 Setup Pages
58
+ - name : 🌐 Setup GitHub Pages
60
59
uses : actions/configure-pages@v5
61
- with :
62
- static_site_generator : next
60
+
61
+ # ========================
62
+ # 🔐 Secrets & Config Setup
63
+ # ========================
64
+ - name : 🔒 Verify Secrets Exist
65
+ run : |
66
+ if [ -z "${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}" ]; then
67
+ echo "❌ Critical error: GOOGLE_SERVICES_JSON_BASE64 secret missing!"
68
+ exit 1
69
+ fi
70
+ echo "✅ All secrets present"
71
+
72
+ - name : 📁 Create google-services.json in Root
73
+ run : |
74
+ echo "$GOOGLE_SERVICES_JSON_BASE64" | base64 --decode > google-services.json
75
+ jq empty google-services.json # Validate JSON
76
+ env :
77
+ GOOGLE_SERVICES_JSON_BASE64 : ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}
63
78
64
79
- name : 📦 Restore cache
65
80
uses : actions/cache@v4
@@ -72,13 +87,17 @@ jobs:
72
87
- name : 📥 Install dependencies
73
88
run : ${{ env.manager }} ${{ env.command }}
74
89
75
- - name : 👷 Build with Next.js
76
- run : ${{ env.runner }} next build
90
+ - name : 🏗 Generate Static Build
91
+ run : |
92
+ echo "⚠️ Exporting static files. Pages with SSR/API routes will be ignored."
93
+ ${{ env.runner }} next build
94
+ ${{ env.runner }} next export
95
+ touch out/.nojekyll # Prevent GitHub from ignoring _next folder
77
96
78
- - name : 📤 Upload artifact
97
+ - name : 📤 Upload static site
79
98
uses : actions/upload-pages-artifact@v3
80
99
with :
81
- path : ./out
100
+ path : ./out # This is where static files go after next export
82
101
83
102
deploy :
84
103
name : 🚀 Deploy to GitHub Pages
0 commit comments