Skip to content

Commit 03f6766

Browse files
Added checks to only output static pages.
1 parent 28988dd commit 03f6766

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

.github/workflows/nextjs-static-gh-pages.yml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 🚀 Deploy Next.js to GitHub Pages
1+
name: 🚀 Deploy Static Next.js to GitHub Pages
22

33
on:
44
push:
@@ -16,7 +16,7 @@ concurrency:
1616

1717
jobs:
1818
build:
19-
name: 🛠️ Build Next.js
19+
name: 🏗 Build Static Next.js
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: 🔍 Checkout repository
@@ -39,7 +39,6 @@ jobs:
3939
echo "runner=npx --no-install" >> $GITHUB_ENV
4040
fi
4141
42-
# ✅ Explicitly Install pnpm before setting up Node.js
4342
- name: 📦 Install pnpm if needed
4443
if: env.manager == 'pnpm'
4544
run: npm install -g pnpm
@@ -56,10 +55,26 @@ jobs:
5655
echo "npm $(npm -v)"
5756
${{ env.manager }} --version
5857
59-
- name: 🌐 Setup Pages
58+
- name: 🌐 Setup GitHub Pages
6059
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 }}
6378

6479
- name: 📦 Restore cache
6580
uses: actions/cache@v4
@@ -72,13 +87,17 @@ jobs:
7287
- name: 📥 Install dependencies
7388
run: ${{ env.manager }} ${{ env.command }}
7489

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
7796
78-
- name: 📤 Upload artifact
97+
- name: 📤 Upload static site
7998
uses: actions/upload-pages-artifact@v3
8099
with:
81-
path: ./out
100+
path: ./out # This is where static files go after next export
82101

83102
deploy:
84103
name: 🚀 Deploy to GitHub Pages

0 commit comments

Comments
 (0)