@@ -19,15 +19,10 @@ jobs:
1919 uses : actions/setup-node@v4
2020 with :
2121 node-version : 20
22+ cache : ' npm'
2223
2324 - name : Install dependencies
24- run : |
25- npm ci || npm install
26- ls -la node_modules/.bin/vite || echo "vite bin MISSING - reinstalling"
27- if [ ! -f node_modules/.bin/vite ]; then
28- npm rebuild vite || true
29- ls -la node_modules/.bin/vite
30- fi
25+ run : npm install --ignore-scripts
3126
3227 - name : Build
3328 run : npm run build
@@ -39,21 +34,10 @@ jobs:
3934 CLOUDFLARE_API_TOKEN : ${{ secrets.CLOUDFLARE_API_TOKEN }}
4035 CLOUDFLARE_ACCOUNT_ID : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
4136 run : |
42- echo "--- CLOUDFLARE_API_TOKEN prefix (first 8 chars) ---"
43- echo "${CLOUDFLARE_API_TOKEN:0:8}..."
44- echo "--- CLOUDFLARE_ACCOUNT_ID ---"
45- echo "$CLOUDFLARE_ACCOUNT_ID"
46- echo "--- Wrangler version ---"
47- npx wrangler --version
48- echo "--- Check if project exists ---"
49- npx wrangler pages project list 2>&1 | tee /tmp/wrangler_list.txt
50- echo "--- Project list done ---"
51- echo "--- wrangler_list.txt content ---"
52- cat /tmp/wrangler_list.txt
53- echo "--- Searching for wuxia-game in list ---"
54- grep -n "wuxia-game\|wuxia" /tmp/wrangler_list.txt || echo "NOT FOUND in list"
55- echo "--- Deploying to Cloudflare Pages ---"
56- npx wrangler pages deploy dist --project-name=wuxia-game --branch=main --commit-message="Deploy from GitHub Actions ${{ github.sha }}" 2>&1 | tee /tmp/wrangler_deploy.txt
57- echo "--- Deploy output ---"
58- cat /tmp/wrangler_deploy.txt
59- echo "--- Deploy done ---"
37+ # 检查项目是否已存在,不存在则创建
38+ if npx wrangler pages project list 2>/dev/null | grep -qw "wuxia-game"; then
39+ echo "Project wuxia-game already exists"
40+ else
41+ npx wrangler pages project create wuxia-game --production-branch=main
42+ fi
43+ npx wrangler pages deploy dist --project-name=wuxia-game --commit-message="Deploy from GitHub Actions"
0 commit comments