Fix static export by excluding API routes during build #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Deploy Next.js to cPanel (Static Export) | |
on: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
build-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "npm" | |
- name: Install deps | |
run: npm ci | |
- name: Build Next.js app (Static Export) | |
env: | |
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }} | |
MONGODB_URI: ${{ secrets.MONGODB_URI }} | |
JWT_SECRET: ${{ secrets.JWT_SECRET }} | |
BREVO_API_KEY: ${{ secrets.BREVO_API_KEY }} | |
run: npm run build # produces out/ | |
- name: Deploy via FTP to cPanel | |
uses: SamKirkland/[email protected] | |
with: | |
server: ${{ secrets.FTP_HOST }} | |
username: ${{ secrets.FTP_USER }} | |
password: ${{ secrets.FTP_PASS }} | |
local-dir: out/ | |
server-dir: / | |
exclude: | | |
**/.git* | |
**/.github* | |
**/node_modules/** | |
**/*.map | |
**/.next/cache/** | |
**/.env* | |
**/README.md | |
**/deploy.yml | |
**/deploy.sh | |
- name: Notify deployment completion | |
run: | | |
echo "🚀 Static deployment completed!" | |
echo "✅ Your site is now live at: https://csulb.acm.org/acm" | |
echo "📝 No manual steps required - static hosting!" |