Repository navigation
116 lines (102 loc) · 3.95 KB
/
Copy pathdeploy.yml
File metadata and controls
116 lines (102 loc) · 3.95 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
name: Build and Deploy Static Export
on:
push:
tags:
- 'v*' # Triggers on any tag starting with 'v' (e.g., v1.0.0, v1.2.3)
pull_request:
branches: [main] # Build PRs for testing, but don't deploy
jobs:
build:
runs-on: ubuntu-latest
environment: deploy
env:
NEXT_PUBLIC_ADSENSE_CLIENT_ID: ${{ vars.NEXT_PUBLIC_ADSENSE_CLIENT_ID }}
NEXT_PUBLIC_ADSENSE_SLOT_ID: ${{ vars.NEXT_PUBLIC_ADSENSE_SLOT_ID }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20' # Updated to match project's Node version requirements
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Build static export
run: npm run build # This will run next build which generates the 'out' directory
- name: Copy Apache configuration
run: cp .htaccess out/.htaccess
- name: Verify build output
run: |
echo "Checking if build succeeded..."
ls -la out/
echo "Build output files:"
find out/ -type f | head -10
- name: Mask serialized FTP credentials
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
env:
FTP_HOST_RAW: ${{ secrets.FTP_HOST }}
FTP_USERNAME_RAW: ${{ secrets.FTP_USERNAME }}
FTP_PASSWORD_RAW: ${{ secrets.FTP_PASSWORD }}
run: |
node <<'NODE'
const names = ['FTP_HOST_RAW', 'FTP_USERNAME_RAW', 'FTP_PASSWORD_RAW'];
const escapeCommandData = (value) => value
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A');
for (const name of names) {
const serialized = JSON.stringify(process.env[name] ?? '');
process.stdout.write(`::add-mask::${escapeCommandData(serialized)}\n`);
}
NODE
- name: Deploy Next.js assets (excluding app chunks)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: Wandalen/wretry.action@v3.8.0
with:
action: SamKirkland/FTP-Deploy-Action@v4.3.6
attempt_limit: 3
attempt_delay: 15000
with: |
server: ${{ toJSON(secrets.FTP_HOST) }}
username: ${{ toJSON(secrets.FTP_USERNAME) }}
password: ${{ toJSON(secrets.FTP_PASSWORD) }}
local-dir: ./out/_next/
server-dir: ./_next/
state-name: .ftp-deploy-sync-state.json
exclude: |
**/static/chunks/app/**
- name: Deploy Next.js app chunks
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: Wandalen/wretry.action@v3.8.0
with:
action: SamKirkland/FTP-Deploy-Action@v4.3.6
attempt_limit: 3
attempt_delay: 15000
with: |
server: ${{ toJSON(secrets.FTP_HOST) }}
username: ${{ toJSON(secrets.FTP_USERNAME) }}
password: ${{ toJSON(secrets.FTP_PASSWORD) }}
local-dir: ./out/_next/static/chunks/app/
server-dir: ./_next/static/chunks/app/
state-name: .ftp-deploy-sync-state.json
- name: Deploy site files to FTP
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: Wandalen/wretry.action@v3.8.0
with:
action: SamKirkland/FTP-Deploy-Action@v4.3.6
attempt_limit: 3
attempt_delay: 15000
with: |
server: ${{ toJSON(secrets.FTP_HOST) }}
username: ${{ toJSON(secrets.FTP_USERNAME) }}
password: ${{ toJSON(secrets.FTP_PASSWORD) }}
local-dir: ./out/
server-dir: ./
exclude: |
**/.git*
**/.git*/**
**/node_modules/**
**/.DS_Store
**/_next/**
dry-run: false