-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (145 loc) · 6.28 KB
/
nextjs.yml
File metadata and controls
155 lines (145 loc) · 6.28 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Workflow for building and deploying a static Next.js site to GitHub Pages
#
# FEATURES:
# ✅ All public-facing pages (Home, Events, Gallery, Live, Travel, Contact, RSVP)
# ✅ Working contact and RSVP forms (using Web3Forms API)
# ✅ All images and static assets
# ✅ Responsive design and mobile-friendly
#
# SETUP REQUIRED:
# 1. Get free Web3Forms API key from https://web3forms.com
# 2. Add as repository secret: WEB3FORMS_ACCESS_KEY
# 3. Add Gmail credentials as repository secrets:
# - GMAIL_USER: Gmail email address
# - GMAIL_APP_PASSWORD: Gmail app password (not regular password)
# - GMAIL_FROM: Display name for emails (e.g., "Wedding <email@domain.com>")
# - TEST_EMAIL_TO: Test recipient email address
# 4. Enable GitHub Pages in repository Settings → Pages → Source: GitHub Actions
#
# EXCLUDED (requires server):
# ❌ API routes (not supported in static export)
# ❌ Admin pages (require authentication)
# ❌ Database operations
#
# For full-featured deployment with backend, see HOSTINGER_VPS_DEPLOYMENT_PLAN.md
# For quick setup instructions, see QUICK_DEPLOY_GITHUB_PAGES.md
#
name: Deploy Next.js site to Pages
on:
# Allows you to run this workflow manually from the 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, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/client/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/client/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}
cache-dependency-path: ${{ steps.detect-package-manager.outputs.manager == 'yarn' && 'client/yarn.lock' || (hashFiles('client/package-lock.json') != '' && 'client/package-lock.json' || 'client/package.json') }}
- name: Setup Pages
uses: actions/configure-pages@v5
with:
# Automatically inject basePath in your Next.js configuration file and disable
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
#
# You may remove this line if you want to manage the configuration yourself.
static_site_generator: next
- name: Restore cache
uses: actions/cache@v4
with:
path: |
client/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**/*.{js,ts}', '**/*.{jsx,tsx}') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Install dependencies
working-directory: ./client
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Create environment file
working-directory: ./client
run: |
echo "Creating environment file for build..."
# NOTE: These values are placeholders to satisfy build requirements
# Static export doesn't use these at runtime (no server-side functionality)
# For full backend functionality, use Hostinger VPS deployment
cat << EOF > .env.local
# Database (placeholder - not functional in static export)
DATABASE_URL="file:./prisma/dev.db"
# NextAuth (placeholder - not functional in static export)
NEXTAUTH_SECRET="wedding-pages-deploy-secret"
NEXTAUTH_URL="http://localhost:3000"
# Email (placeholder - not functional in static export)
RESEND_API_KEY="re_placeholder"
# Gmail credentials for email functionality (from GitHub Secrets)
GMAIL_USER="${{ secrets.GMAIL_USER }}"
GMAIL_APP_PASSWORD="${{ secrets.GMAIL_APP_PASSWORD }}"
GMAIL_FROM="${{ secrets.GMAIL_FROM }}"
TEST_EMAIL_TO="${{ secrets.TEST_EMAIL_TO }}"
# Cloudinary (set to empty for GitHub Pages deployment)
CLOUDINARY_CLOUD_NAME=""
CLOUDINARY_API_KEY=""
CLOUDINARY_API_SECRET=""
# Web3Forms for static form submissions
# Get your free access key at https://web3forms.com
# Add as repository secret: WEB3FORMS_ACCESS_KEY
NEXT_PUBLIC_WEB3FORMS_KEY="${{ secrets.WEB3FORMS_ACCESS_KEY }}"
EOF
echo "Environment file created"
echo "Web3Forms key configured: ${{ secrets.WEB3FORMS_ACCESS_KEY != '' && 'Yes' || 'No (using fallback)' }}"
- name: Generate Prisma client
working-directory: ./client
run: npx prisma generate
- name: Build with Next.js (static export)
working-directory: ./client
env:
DEPLOY_TARGET: "github-pages"
run: npm run build:static
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./client/out
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4