Skip to content

Commit a7fee23

Browse files
committed
ci: Next static export + FTP deploy
1 parent ea6f925 commit a7fee23

File tree

5 files changed

+57
-3
lines changed

5 files changed

+57
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ yarn-error.log*
3030

3131
# env files
3232
.env
33+
.env.*
34+
!.env.example
3335

3436
# vercel
3537
.vercel

.htaccess

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
RewriteEngine On
2+
RewriteBase /
3+
RewriteRule ^index\.html$ - [L]
4+
RewriteCond %{REQUEST_FILENAME} !-f
5+
RewriteCond %{REQUEST_FILENAME} !-d
6+
RewriteRule . /index.html [L]

deploy.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build & Deploy Next.js to cPanel via FTP
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: 20
17+
cache: 'npm'
18+
19+
- name: Install deps
20+
run: npm ci
21+
22+
- name: Build (Next static export)
23+
env:
24+
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }}
25+
run: npm run build # produces out/
26+
27+
- name: Deploy via FTP to cPanel
28+
uses: SamKirkland/FTP-Deploy-Action@v4
29+
with:
30+
server: ${{ secrets.FTP_HOST }}
31+
username: ${{ secrets.FTP_USER }}
32+
password: ${{ secrets.FTP_PASS }}
33+
local-dir: out/
34+
server-dir: public_html/
35+
exclude: |
36+
**/.git*
37+
**/.github*
38+
**/node_modules/**
39+
**/*.map

next.config.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
/** @type {import('next').NextConfig} */
2-
const nextConfig = {};
3-
2+
const nextConfig = {
3+
output: 'export', // static export
4+
images: { unoptimized: true }, // needed when exporting
5+
// If deploying to a subfolder like /app:
6+
// basePath: '/app',
7+
// assetPrefix: '/app/',
8+
// trailingSlash: true,
9+
};
410
export default nextConfig;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"dev": "next dev",
77
"build": "next build",
88
"start": "next start",
9-
"lint": "next lint"
9+
"lint": "next lint",
10+
"export": "next export"
1011
},
1112
"dependencies": {
1213
"@fortawesome/free-brands-svg-icons": "^6.6.0",

0 commit comments

Comments
 (0)