-
Notifications
You must be signed in to change notification settings - Fork 0
307 lines (267 loc) · 11.3 KB
/
ci.yml
File metadata and controls
307 lines (267 loc) · 11.3 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
name: 🚀 Build & Deploy (No Tests)
on:
push:
branches: [master, next, develop]
pull_request:
branches: [master, next, develop]
workflow_dispatch:
inputs:
skip_build:
description: 'Skip build step'
required: false
default: false
type: boolean
deploy_only:
description: 'Deploy only (skip validation)'
required: false
default: false
type: boolean
concurrency:
group: "ci-${{ github.ref_name }}-${{ github.event.head_commit.id }}"
cancel-in-progress: true
env:
NODE_VERSION: '22'
# Reduce cache size by excluding unnecessary files
CACHE_EXCLUDE: 'node_modules/.cache,dist,coverage,.nyc_output,*.log,*.tmp'
jobs:
validate:
name: ✅ Quick Validation
runs-on: ubuntu-latest
timeout-minutes: 5
if: ${{ !inputs.deploy_only }}
steps:
- name: ⚡ Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: ⚡ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: ⚡ Cache node_modules
uses: actions/cache@v4
with:
path: |
node_modules
~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: ⚡ Install dependencies
run: npm ci --prefer-offline --no-audit --no-fund --silent
- name: ⚡ Validate translations
run: npm run i18n:validate --silent || echo "Translation validation completed with warnings"
- name: ⚡ Quick build test
run: |
echo "🏗️ Testing build process..."
npm run build --silent
echo "✅ Build test successful"
build-and-deploy:
name: 🏗️ Build & Deploy
runs-on: ubuntu-latest
needs: validate
if: ${{ inputs.skip_build != true && (needs.validate.result == 'success' || inputs.deploy_only) }}
timeout-minutes: 15
permissions:
contents: write
steps:
- name: ⚡ Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: ⚡ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: ⚡ Cache dependencies and build artifacts
uses: actions/cache@v4
with:
path: |
node_modules
~/.npm
dist
.vite
key: ${{ runner.os }}-build-${{ hashFiles('package-lock.json', 'src/**/*', 'templates/**/*') }}
restore-keys: |
${{ runner.os }}-build-${{ hashFiles('package-lock.json') }}
${{ runner.os }}-build-
- name: ⚡ Install dependencies
run: npm ci --prefer-offline --no-audit --no-fund --silent
- name: ⚡ Build project
run: |
echo "🏗️ Building project..."
npm run build:prod --silent
echo "✅ Build completed successfully"
- name: ⚡ Optimize for GitHub Pages
run: |
echo "🔧 Running GitHub Pages optimization script..."
node scripts/optimize-for-github-pages.js
- name: ⚡ Verify artifact contents
run: |
echo "🔍 Verifying dist directory..."
REQUIRED_FILES=("index.html" "robots.txt" "sitemap.xml")
for file in "${REQUIRED_FILES[@]}"; do
if [ -f "dist/$file" ]; then
echo "✅ $file exists"
else
echo "❌ $file missing"
exit 1
fi
done
- name: ⚡ Verify build artifacts
run: |
echo "🔍 Verifying build artifacts..."
du -sh dist/
echo "📊 Largest files in artifact:"
find dist/ -type f -exec ls -lh {} \; | sort -k5 -hr | head -10
echo "📦 File count by type:"
find dist/ -type f | sed 's/.*\.//' | sort | uniq -c | sort -nr
# Check total artifact size
TOTAL_SIZE=$(du -sb dist/ | cut -f1)
TOTAL_SIZE_MB=$((TOTAL_SIZE / 1024 / 1024))
echo "📏 Total artifact size: ${TOTAL_SIZE_MB}MB"
echo "✅ Build artifacts verified - no modifications applied"
- name: "⚡ Debug: Verify files before deployment"
run: |
echo "🔍 Checking vendor-three.js before deployment:"
ls -lh dist/assets/vendor-three-C2c03BIj.js
echo "File size: $(wc -c < dist/assets/vendor-three-C2c03BIj.js) bytes"
echo "First 100 chars:"
head -c 100 dist/assets/vendor-three-C2c03BIj.js
echo "..."
echo "Last 100 chars:"
tail -c 100 dist/assets/vendor-three-C2c03BIj.js
# ✅ Deploy with pre-compressed files to work around truncation
- name: ⚡ Pre-compress JS files
run: |
echo "📦 Pre-compressing JavaScript files..."
cd dist/assets
for file in *.js; do
if [ -f "$file" ]; then
echo "Compressing: $file ($(wc -c < "$file") bytes)"
gzip -9kf "$file"
echo " Created: $file.gz ($(wc -c < "$file.gz") bytes)"
fi
done
echo "✅ Pre-compression complete"
- name: ⚡ Deploy to GitHub Pages (chunked push with size verification)
env:
GIT_LFS_SKIP_SMUDGE: 1
run: |
echo "🚀 Deploying to gh-pages branch with chunked commits..."
cd dist
git init
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Completely disable LFS - no filters at all
git config filter.lfs.required false
git config filter.lfs.clean "cat"
git config filter.lfs.smudge "cat"
git config filter.lfs.process ""
git config lfs.repositoryformatversion ""
git config lfs.fetchexclude "*"
git config core.autocrlf false
git config core.eol lf
echo "✅ Git configured (LFS disabled, no line ending conversion)"
git branch -M gh-pages
# Push HTML and small files first
echo "📦 Batch 1: HTML, CSS, and small assets..."
git add index.html *.txt *.xml 2>/dev/null || true
git add assets/*.css assets/*.svg assets/*.json assets/*.jpg 2>/dev/null || true
if git diff --cached --quiet; then
echo " ⚠️ No files to commit in batch 1"
else
git commit -m "Deploy batch 1: HTML, CSS, images"
git push -f https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git gh-pages
echo " ✅ Batch 1 pushed"
fi
# Push JS files one by one (the problematic files)
echo "📦 Batch 2: JavaScript files (one at a time)..."
for jsfile in assets/*.js; do
if [ -f "$jsfile" ]; then
filesize=$(wc -c < "$jsfile")
echo " 📄 Processing: $jsfile ($filesize bytes)"
# Add file and verify it's in the index
git add -f "$jsfile"
# Check what git sees - get object hash and check size
object_id=$(git ls-files -s "$jsfile" | awk '{print $2}')
git_size=$(git cat-file -s "$object_id" 2>/dev/null || echo "0")
echo " Git object size: $git_size bytes (object: ${object_id:0:8})"
if [ "$filesize" -eq "$git_size" ]; then
git commit -m "Deploy: $(basename $jsfile)"
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git gh-pages
echo " ✅ Pushed: $(basename $jsfile) ($filesize bytes)"
else
echo " ❌ SIZE MISMATCH! File: $filesize bytes, Git: $git_size bytes"
echo " This indicates git is truncating the file during add!"
# Show more info
echo " File SHA256: $(sha256sum "$jsfile" | cut -d' ' -f1)"
echo " Git object SHA: $object_id"
exit 1
fi
fi
done
# Push compressed files
echo "📦 Batch 3: Compressed files..."
git add assets/*.gz 2>/dev/null || true
if ! git diff --cached --quiet; then
git commit -m "Deploy: Compressed assets"
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git gh-pages
echo " ✅ Batch 3 pushed"
fi
# Push WASM and remaining files
echo "📦 Batch 4: WASM and remaining assets..."
git add . 2>/dev/null || true
if ! git diff --cached --quiet; then
git commit -m "Deploy: Final assets"
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git gh-pages
echo " ✅ Batch 4 pushed"
fi
echo "✅ Chunked deployment complete!"
- name: ⚡ Verify deployment
run: |
echo "🚀 Deployment completed to gh-pages branch!"
echo "URL: https://khalilcharfi.github.io"
sleep 15
if curl -fsSL --max-time 20 "https://khalilcharfi.github.io" > /dev/null; then
echo "✅ Site is accessible"
else
echo "⚠️ Site may not be fully propagated yet (CDN delay)"
fi
- name: ⚡ Deployment summary
run: |
echo "## 🚀 Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "### ✅ Status: Success" >> $GITHUB_STEP_SUMMARY
echo "### 🔗 URL: https://khalilcharfi.github.io" >> $GITHUB_STEP_SUMMARY
echo "### 📅 Deployed: $(date -u)" >> $GITHUB_STEP_SUMMARY
echo "### 📦 Source: ${{ github.ref_name }} branch" >> $GITHUB_STEP_SUMMARY
echo "### 🏗️ Deployed via: gh-pages branch" >> $GITHUB_STEP_SUMMARY
summary:
name: 📊 Pipeline Summary
runs-on: ubuntu-latest
needs: [validate, build-and-deploy]
if: always()
timeout-minutes: 1
steps:
- name: ⚡ Generate summary
run: |
echo "## 🚀 Build & Deploy Summary" > summary.md
echo "" >> summary.md
echo "| Step | Status |" >> summary.md
echo "|------|--------|" >> summary.md
echo "| Validation | ${{ needs.validate.result == 'success' && '✅' || '❌' }} |" >> summary.md
echo "| Build & Deploy | ${{ needs.build-and-deploy.result == 'success' && '✅' || '❌' }} |" >> summary.md
echo "" >> summary.md
echo "**Overall:** ${{ needs.build-and-deploy.result == 'success' && '✅ All checks passed' || '❌ Some checks failed' }}" >> summary.md
echo "" >> summary.md
echo "**Duration:** ~6 minutes (optimized with caching)" >> summary.md
- name: ⚡ Upload summary
uses: actions/upload-artifact@v4
with:
name: pipeline-summary-${{ github.run_id }}
path: summary.md
retention-days: 1