diff --git a/.github/actions/deploy-cf/action.yml b/.github/actions/deploy-cf/action.yml index 520d26c..c39322d 100644 --- a/.github/actions/deploy-cf/action.yml +++ b/.github/actions/deploy-cf/action.yml @@ -289,9 +289,10 @@ runs: key: frontend-node-${{ hashFiles('frontend/package-lock.json') }} - name: Install worker dependencies + if: steps.cache-worker.outputs.cache-hit != 'true' working-directory: worker shell: bash - run: npm install + run: npm ci - name: Build working-directory: worker diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af37f6d..3c27a14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,8 +22,6 @@ jobs: node-version: '22' cache: npm cache-dependency-path: backend/package-lock.json - # 直接缓存 node_modules:better-sqlite3 是原生模块,~/.npm 缓存命中后 npm ci 仍要 - # 重新解压并下载/编译原生二进制,波动大。命中 node_modules 后直接跳过 npm ci。 - name: Cache backend node_modules id: cache-backend uses: actions/cache@v5 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3214127..c9be148 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -92,8 +92,9 @@ jobs: key: frontend-node-${{ hashFiles('frontend/package-lock.json') }} - name: Install worker dependencies + if: steps.cache-worker.outputs.cache-hit != 'true' working-directory: worker - run: npm install + run: npm ci - name: Build and package working-directory: worker diff --git a/worker/build.js b/worker/build.js index ceb3e00..986e700 100644 --- a/worker/build.js +++ b/worker/build.js @@ -98,7 +98,7 @@ console.log(` Set OBFUSCATE_FRONTEND=true to enable frontend obfuscation`); console.log(` Set OBFUSCATE_WORKER=true to enable worker obfuscation (may break on Cloudflare)\n`); console.log(`[${++step}/${totalSteps}] Installing frontend dependencies...`); -execSync('npm install', { cwd: frontendDir, stdio: 'inherit' }); +execSync('npm ci', { cwd: frontendDir, stdio: 'inherit' }); console.log(`[${++step}/${totalSteps}] Building frontend (base=/admin/)...`); execSync('npm run build', {