Skip to content

Commit 54debaa

Browse files
authored
Deploy Next.js wedding website to GitHub Pages with SQLite support (#231)
2 parents be7d7b0 + 3dfa031 commit 54debaa

File tree

13 files changed

+487
-52
lines changed

13 files changed

+487
-52
lines changed

.github/workflows/nextjs.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# Sample workflow for building and deploying a Next.js site to GitHub Pages
1+
# Workflow for building and deploying a static Next.js site to GitHub Pages
22
#
3-
# To get started with Next.js see: https://nextjs.org/docs/getting-started
4-
#
5-
# NOTE: This workflow is currently NOT FUNCTIONAL for this project because:
6-
# - Static export (output: 'export') is disabled due to NextAuth incompatibility
7-
# - The application requires server-side functionality (API routes, authentication)
8-
# - For production deployment, use Hostinger VPS deployment instead
9-
# - See HOSTINGER_VPS_DEPLOYMENT_PLAN.md and ci-cd-pipeline.yml for proper deployment
3+
# NOTE: This workflow builds a static-only version of the site without:
4+
# - API routes (forms will show email contact information instead)
5+
# - Admin pages (authentication requires server-side functionality)
6+
# - For full-featured deployment with backend, use Hostinger VPS deployment
7+
# - See HOSTINGER_VPS_DEPLOYMENT_PLAN.md and ci-cd-pipeline.yml for server deployment
108
#
119
name: Deploy Next.js site to Pages
1210

@@ -85,9 +83,9 @@ jobs:
8583
working-directory: ./client
8684
run: |
8785
echo "Creating environment file for build..."
88-
# NOTE: These values are placeholders only to satisfy build requirements
89-
# Since static export is disabled, this workflow won't actually deploy
90-
# In production, use proper secrets and Hostinger VPS deployment
86+
# NOTE: These values are placeholders to satisfy build requirements
87+
# Static export doesn't use these at runtime (no server-side functionality)
88+
# For full backend functionality, use Hostinger VPS deployment
9189
cat << EOF > .env.local
9290
# Database (placeholder - not functional in static export)
9391
DATABASE_URL="file:./prisma/dev.db"
@@ -108,13 +106,13 @@ jobs:
108106
- name: Generate Prisma client
109107
working-directory: ./client
110108
run: npx prisma generate
111-
- name: Build with Next.js
109+
- name: Build with Next.js (static export)
112110
working-directory: ./client
113-
run: ${{ steps.detect-package-manager.outputs.runner }} next build
111+
run: npm run build:static
114112
- name: Upload artifact
115113
uses: actions/upload-pages-artifact@v3
116114
with:
117-
path: ./client/.next
115+
path: ./client/out
118116

119117
# Deployment job
120118
deploy:

DEPLOYMENT_CHANGES_SUMMARY.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Deployment Changes Summary
2+
3+
This document summarizes the changes made to enable GitHub Pages deployment for the Sharothee Wedding website.
4+
5+
## Changes Made
6+
7+
### 1. Database Configuration
8+
**File**: `client/prisma/schema.prisma`
9+
- Changed database provider from `mysql` to `sqlite`
10+
- Updated datasource configuration to use SQLite file
11+
12+
### 2. Next.js Configuration
13+
**File**: `client/next.config.ts`
14+
- Enabled static export: `output: 'export'`
15+
- Added basePath for subdirectory deployment: `/Sharothee-Wedding-arvinwedsincia`
16+
- Added assetPrefix for proper asset loading
17+
- Enabled trailing slashes for GitHub Pages compatibility
18+
- Set images to unoptimized mode for static export
19+
20+
### 3. Build Scripts
21+
**Created Files**:
22+
- `client/scripts/prepare-static-build.sh` - Moves API routes and admin pages before build
23+
- `client/scripts/restore-after-build.sh` - Restores moved directories after build
24+
25+
**Updated File**: `client/package.json`
26+
- Added `build:static` script: Runs prepare → build → restore sequence
27+
- Updated `build:github` to use `build:static`
28+
29+
### 4. Form Handling Updates
30+
**Modified Files**:
31+
- `client/src/app/rsvp/page.tsx` - Added static mode detection and email fallback
32+
- `client/src/app/contact/page.tsx` - Added static mode detection and email fallback
33+
34+
Both forms now:
35+
- Detect when running in static export mode
36+
- Show success message with email contact information
37+
- Maintain client-side validation
38+
39+
### 5. GitHub Actions Workflow
40+
**File**: `.github/workflows/nextjs.yml`
41+
- Updated comments to reflect static export functionality
42+
- Changed build command to use `npm run build:static`
43+
- Updated artifact path to `client/out` (static export output)
44+
- Updated environment file creation comments
45+
46+
### 6. GitHub Pages Configuration
47+
**Created Files**:
48+
- `client/public/.nojekyll` - Prevents Jekyll processing on GitHub Pages
49+
- `GITHUB_PAGES_DEPLOYMENT.md` - Complete deployment documentation
50+
51+
**Updated File**: `client/.gitignore`
52+
- Added `.build-backup` directory to ignore list
53+
54+
## Technical Details
55+
56+
### Static Export Process
57+
1. **Preparation**: API routes and admin directories are temporarily moved to `.build-backup`
58+
2. **Build**: Next.js generates static HTML/CSS/JS files in `out` directory
59+
3. **Restore**: Moved directories are restored for development use
60+
61+
### Output Structure
62+
```
63+
client/out/
64+
├── .nojekyll # Prevents Jekyll processing
65+
├── index.html # Home page
66+
├── 404.html # 404 error page
67+
├── events/index.html # Events page
68+
├── gallery/index.html # Gallery page
69+
├── live/index.html # Live stream page
70+
├── rsvp/index.html # RSVP page
71+
├── contact/index.html # Contact page
72+
├── travel/index.html # Travel info page
73+
├── _next/ # Next.js static assets
74+
├── images/ # Static images
75+
└── favicon.ico # Favicon
76+
```
77+
78+
### BasePath Configuration
79+
All URLs and asset paths include the basePath `/Sharothee-Wedding-arvinwedsincia` for subdirectory deployment.
80+
81+
Example:
82+
- Image: `/Sharothee-Wedding-arvinwedsincia/images/photo.jpg`
83+
- Link: `/Sharothee-Wedding-arvinwedsincia/events/`
84+
- Script: `/Sharothee-Wedding-arvinwedsincia/_next/static/chunks/...`
85+
86+
## What's Excluded from Static Build
87+
88+
The following directories are temporarily moved during build:
89+
- `src/app/api/` - All API routes (18 files)
90+
- `src/app/admin/` - Admin dashboard pages (10 files)
91+
92+
These are restored after build for local development but not included in the static export.
93+
94+
## Environment Variables
95+
96+
The workflow creates a minimal `.env.local` file with placeholder values:
97+
- `DATABASE_URL` - Points to SQLite file (not used at runtime)
98+
- `NEXTAUTH_SECRET` - Placeholder (authentication not used)
99+
- `NEXTAUTH_URL` - Placeholder (authentication not used)
100+
- Email and Cloudinary keys - Placeholders (not functional in static mode)
101+
102+
## Testing Locally
103+
104+
```bash
105+
cd client
106+
npm run build:static
107+
cd out
108+
python3 -m http.server 8000
109+
110+
# Visit: http://localhost:8000
111+
# Note: BasePath required for full testing
112+
```
113+
114+
## Deployment URL
115+
116+
Once merged and deployed:
117+
**https://codestorm-hub.github.io/Sharothee-Wedding-arvinwedsincia/**
118+
119+
## Migration Notes
120+
121+
For full server functionality (API routes, authentication, database):
122+
1. Deploy to Hostinger VPS instead
123+
2. Use MySQL database
124+
3. Remove `output: 'export'` from next.config.ts
125+
4. Keep basePath empty in production
126+
5. Configure proper environment variables
127+
128+
See `HOSTINGER_VPS_DEPLOYMENT_PLAN.md` for VPS deployment instructions.
129+
130+
## Files Changed
131+
132+
### Modified (10 files)
133+
1. `.github/workflows/nextjs.yml`
134+
2. `client/.gitignore`
135+
3. `client/next.config.ts`
136+
4. `client/package.json`
137+
5. `client/prisma/schema.prisma`
138+
6. `client/src/app/contact/page.tsx`
139+
7. `client/src/app/rsvp/page.tsx`
140+
141+
### Created (4 files)
142+
8. `client/public/.nojekyll`
143+
9. `client/scripts/prepare-static-build.sh`
144+
10. `client/scripts/restore-after-build.sh`
145+
11. `GITHUB_PAGES_DEPLOYMENT.md`
146+
12. `DEPLOYMENT_CHANGES_SUMMARY.md` (this file)
147+
148+
## Verification Checklist
149+
150+
- [x] Static build completes successfully
151+
- [x] All 11 pages generated (including 404)
152+
- [x] BasePath correctly applied to all URLs
153+
- [x] .nojekyll file included in output
154+
- [x] API routes and admin pages excluded
155+
- [x] Forms show email fallback
156+
- [x] GitHub Actions workflow updated
157+
- [x] Documentation created
158+
159+
## Support
160+
161+
For questions or issues:
162+
- **Email**: codestromhub@gmail.com
163+
- **Repository**: https://github.com/CodeStorm-Hub/Sharothee-Wedding-arvinwedsincia

GITHUB_PAGES_DEPLOYMENT.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# GitHub Pages Deployment Guide
2+
3+
This document explains how the wedding website is deployed to GitHub Pages as a static site.
4+
5+
## Overview
6+
7+
The website is deployed as a static Next.js export to GitHub Pages at:
8+
**https://codestorm-hub.github.io/Sharothee-Wedding-arvinwedsincia/**
9+
10+
## Static Export Configuration
11+
12+
### What's Included
13+
- ✅ All public-facing pages (Home, Events, Gallery, Live, Travel)
14+
- ✅ RSVP and Contact pages (with email fallback)
15+
- ✅ SQLite database schema (for development reference)
16+
- ✅ Responsive design and all UI features
17+
- ✅ Static images and assets
18+
19+
### What's Excluded
20+
- ❌ API routes (not supported in static export)
21+
- ❌ Admin pages (require authentication)
22+
- ❌ Server-side functionality (forms, database operations)
23+
- ❌ NextAuth authentication
24+
25+
## Build Process
26+
27+
The static build uses a special process to exclude server-dependent features:
28+
29+
1. **Preparation**: `scripts/prepare-static-build.sh` temporarily moves API and admin directories
30+
2. **Build**: Next.js exports the site to the `out` directory with proper basePath
31+
3. **Restore**: `scripts/restore-after-build.sh` brings back the moved directories
32+
33+
### Build Commands
34+
35+
```bash
36+
# Local build for GitHub Pages
37+
cd client
38+
npm run build:static
39+
40+
# Output directory
41+
# All static files are in ./out/
42+
```
43+
44+
## Configuration Details
45+
46+
### next.config.ts
47+
```typescript
48+
output: 'export',
49+
basePath: '/Sharothee-Wedding-arvinwedsincia',
50+
assetPrefix: '/Sharothee-Wedding-arvinwedsincia',
51+
trailingSlash: true,
52+
images: {
53+
unoptimized: true,
54+
}
55+
```
56+
57+
### Database
58+
- **Development**: SQLite at `prisma/dev.db`
59+
- **Production (GitHub Pages)**: No database (static content only)
60+
- **For full backend**: Deploy to Hostinger VPS (see `HOSTINGER_VPS_DEPLOYMENT_PLAN.md`)
61+
62+
## GitHub Actions Workflow
63+
64+
The deployment is automated via `.github/workflows/nextjs.yml`:
65+
66+
1. Checkout repository
67+
2. Setup Node.js 20
68+
3. Install dependencies
69+
4. Generate Prisma client
70+
5. Run `npm run build:static`
71+
6. Upload `client/out` directory to GitHub Pages
72+
7. Deploy to GitHub Pages
73+
74+
## Form Handling in Static Mode
75+
76+
Since API routes don't work in static export, forms have been modified:
77+
78+
### RSVP Form
79+
- Shows success message with email contact information
80+
- Suggests emailing: `arvincia@sparrow-group.com`
81+
- Form validation still works client-side
82+
83+
### Contact Form
84+
- Shows success message with email contact information
85+
- Suggests emailing: `arvincia@sparrow-group.com`
86+
- Form validation still works client-side
87+
88+
## Local Testing
89+
90+
To test the static build locally:
91+
92+
```bash
93+
cd client
94+
95+
# Build the static site
96+
npm run build:static
97+
98+
# Serve the out directory
99+
cd out
100+
python3 -m http.server 8000
101+
102+
# Visit: http://localhost:8000
103+
# Note: Add basePath manually: http://localhost:8000/Sharothee-Wedding-arvinwedsincia/
104+
```
105+
106+
## Deployment Workflow
107+
108+
### Automatic Deployment
109+
1. Push changes to the `main` branch
110+
2. GitHub Actions workflow runs automatically
111+
3. Site builds and deploys to GitHub Pages
112+
4. Visit: https://codestorm-hub.github.io/Sharothee-Wedding-arvinwedsincia/
113+
114+
### Manual Deployment
115+
```bash
116+
# From Actions tab in GitHub
117+
1. Go to "Actions" tab
118+
2. Select "Deploy Next.js site to Pages" workflow
119+
3. Click "Run workflow"
120+
4. Select branch and click "Run workflow"
121+
```
122+
123+
## Troubleshooting
124+
125+
### 404 Error on GitHub Pages
126+
- Ensure GitHub Pages is enabled in repository settings
127+
- Check that source is set to "GitHub Actions"
128+
- Verify `.nojekyll` file exists in `out` directory
129+
- Wait 2-3 minutes after deployment for changes to propagate
130+
131+
### Build Failures
132+
- Check that `.env.local` file exists with required variables
133+
- Ensure Prisma client is generated: `npx prisma generate`
134+
- Verify all dependencies are installed: `npm install`
135+
136+
### Missing Assets
137+
- Check `next.config.ts` has correct basePath
138+
- Ensure images are in `public/images/` directory
139+
- Verify `.nojekyll` file prevents Jekyll processing
140+
141+
## Migration to Full Server
142+
143+
For full functionality with API routes and authentication:
144+
145+
1. See `HOSTINGER_VPS_DEPLOYMENT_PLAN.md`
146+
2. Use MySQL database instead of SQLite
147+
3. Enable server-side features in `next.config.ts`
148+
4. Deploy to VPS with Node.js runtime
149+
150+
## Support
151+
152+
For issues or questions:
153+
- Email: codestromhub@gmail.com
154+
- Phone: +880 1234-567890
155+
- Location: Dhaka, Bangladesh

0 commit comments

Comments
 (0)