Skip to content

Commit dddf630

Browse files
author
Hermes Cron
committed
fix: 修复 GitHub Actions npm install 失败 (npm 10.8.2 Exit handler never called bug)
1 parent 9080725 commit dddf630

2 files changed

Lines changed: 11 additions & 32 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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"

.github/workflows/release.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,10 @@ jobs:
1818
uses: actions/setup-node@v4
1919
with:
2020
node-version: '20'
21+
cache: 'npm'
2122

2223
- name: Install dependencies
23-
run: |
24-
npm ci || npm install
25-
ls -la node_modules/.bin/vite || echo "vite bin MISSING - reinstalling"
26-
if [ ! -f node_modules/.bin/vite ]; then
27-
npm rebuild vite || true
28-
ls -la node_modules/.bin/vite
29-
fi
24+
run: npm install --ignore-scripts
3025

3126
- name: Build
3227
run: npm run build

0 commit comments

Comments
 (0)