@@ -168,17 +168,9 @@ jobs:
168168 fi
169169 echo "✅ Build successful: $(find public -type f | wc -l) files generated"
170170
171- - name : Upload build artifacts
172- uses : actions/upload-artifact@v4
173- with :
174- name : github-pages
175- path : ./src/public
176- retention-days : 7
177- if-no-files-found : error
178-
179- - name : Verify artifact upload
171+ - name : Verify build output
180172 run : |
181- echo "📦 Verifying artifact upload ..."
173+ echo "📦 Verifying build output ..."
182174 if [ -d "./public" ]; then
183175 echo "✅ Public directory exists with $(find ./public -type f | wc -l) files"
184176 ls -la ./public/ | head -5
@@ -203,29 +195,94 @@ jobs:
203195 url : ${{ steps.deployment.outputs.page_url }}
204196
205197 steps :
206- - name : Download build artifacts
207- uses : actions/download-artifact@v4
198+ - name : Checkout repository
199+ uses : actions/checkout@v4
200+
201+ - name : Setup Node.js
202+ uses : actions/setup-node@v4
208203 with :
209- name : github-pages
210- path : ./site-build
204+ node-version : " 20"
205+ cache : " npm"
206+ cache-dependency-path : " ./src/package-lock.json"
211207
212- - name : Verify downloaded artifacts
208+ - name : Install dependencies
209+ run : npm ci --prefer-offline --no-audit
210+ working-directory : ./src
211+
212+ - name : Build site
213+ run : npm run build
214+ env :
215+ NODE_ENV : production
216+ working-directory : ./src
217+
218+ - name : Clean problematic files
213219 run : |
214- echo "📦 Verifying downloaded artifacts..."
215- if [ ! -d "./site-build" ]; then
216- echo "❌ Site build directory not found"
217- echo "🔍 Checking available artifacts..."
218- echo "Current directory: $(pwd)"
219- ls -la
220+ echo "🧹 Cleaning problematic files..."
221+
222+ # 检查 public 目录是否存在
223+ if [ ! -d "public" ]; then
224+ echo "⚠️ Public directory not found, skipping cleanup"
225+ exit 0
226+ fi
227+
228+ echo "📊 Checking artifact size and content..."
229+
230+ # 删除 Zone.Identifier 文件
231+ find ./public -name "*:Zone.Identifier" -type f -delete
232+ find ./public -name "*.Zone.Identifier" -type f -delete
233+
234+ # 删除其他可能包含冒号的文件
235+ find ./public -name "*:*" -type f -delete
236+
237+ # 删除隐藏文件
238+ find ./public -name ".*" -type f -delete
239+
240+ # 删除 macOS 系统文件
241+ find ./public -name ".DS_Store" -type f -delete
242+ find ./public -name "Thumbs.db" -type f -delete
243+
244+ # 删除符号链接
245+ find ./public -type l -delete
246+
247+ # 处理硬链接(保留一个副本,删除重复的)
248+ echo "🔍 Checking for hard links..."
249+ find ./public -type f -exec ls -i {} \; | awk '{print $1}' | sort | uniq -d | while read inode; do
250+ echo "⚠️ Found hard links with inode $inode"
251+ # 找到所有具有相同 inode 的文件
252+ files=$(find ./public -type f -inum "$inode")
253+ # 保留第一个文件,删除其余的
254+ first_file=$(echo "$files" | head -1)
255+ echo " Keeping: $first_file"
256+ echo "$files" | tail -n +2 | xargs rm -f
257+ done
258+
259+ # 检查总大小
260+ TOTAL_SIZE_BYTES=$(du -sb ./public | cut -f1)
261+ TOTAL_SIZE_GB=$(echo "scale=2; $TOTAL_SIZE_BYTES / 1024 / 1024 / 1024" | bc -l 2>/dev/null || echo "0")
262+ echo "📊 Total artifact size: $(du -sh ./public | cut -f1) ($TOTAL_SIZE_GB GB)"
263+
264+ # 检查是否超过 10GB 限制
265+ if (( $(echo "$TOTAL_SIZE_GB > 10" | bc -l) )); then
266+ echo "❌ Artifact size exceeds 10GB limit: $TOTAL_SIZE_GB GB"
267+ echo "🔍 Largest files:"
268+ find ./public -type f -exec ls -lh {} \; | sort -k5 -hr | head -10
220269 exit 1
221270 fi
222- echo "✅ Found $(find ./site-build -type f | wc -l) files in site-build"
223- ls -la ./site-build/ | head -10
271+
272+ # 检查文件数量
273+ FILE_COUNT=$(find ./public -type f | wc -l)
274+ echo "📊 Total files: $FILE_COUNT"
275+
276+ # 列出最大的文件
277+ echo "🔍 Largest files:"
278+ find ./public -type f -exec ls -lh {} \; | sort -k5 -hr | head -5
279+
280+ echo "✅ Problematic files cleaned"
224281
225282 - name : Upload Pages artifact
226283 uses : actions/upload-pages-artifact@v3
227284 with :
228- path : ./site-build
285+ path : ./src/public
229286
230287 - name : Deploy to GitHub Pages
231288 id : deployment
0 commit comments