|
18 | 18 | uses: actions/setup-node@v6 |
19 | 19 | with: |
20 | 20 | node-version: '21' |
21 | | - cache : npm |
| 21 | + cache: false # IMPORTANT: disable built-in cache |
| 22 | + |
| 23 | + # Normalize runner.arch (same role as in setup-go) |
| 24 | + - name: Normalize runner architecture (Linux/macOS) |
| 25 | + if: runner.os != 'Windows' |
| 26 | + shell: bash |
| 27 | + run: | |
| 28 | + echo "ARCH=$(echo '${{ runner.arch }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV |
| 29 | +
|
| 30 | + - name: Normalize runner architecture (Windows) |
| 31 | + if: runner.os == 'Windows' |
| 32 | + shell: pwsh |
| 33 | + run: | |
| 34 | + "ARCH=$($env:RUNNER_ARCH.ToLower())" | Out-File $env:GITHUB_ENV -Append |
| 35 | +
|
| 36 | + # Node equivalent of `go env GOMODCACHE` |
| 37 | + - name: Set Node cache path (Linux/macOS) |
| 38 | + if: runner.os != 'Windows' |
| 39 | + shell: bash |
| 40 | + run: | |
| 41 | + if [ -f pnpm-lock.yaml ]; then |
| 42 | + echo "NODE_CACHE=$(pnpm store path)" >> $GITHUB_ENV |
| 43 | + elif [ -f yarn.lock ]; then |
| 44 | + echo "NODE_CACHE=$(yarn cache dir)" >> $GITHUB_ENV |
| 45 | + else |
| 46 | + echo "NODE_CACHE=$(npm config get cache)" >> $GITHUB_ENV |
| 47 | + fi |
| 48 | +
|
| 49 | + - name: Set Node cache path (Windows) |
| 50 | + if: runner.os == 'Windows' |
| 51 | + shell: pwsh |
| 52 | + run: | |
| 53 | + if (Test-Path pnpm-lock.yaml) { |
| 54 | + $cache = pnpm store path |
| 55 | + } elseif (Test-Path yarn.lock) { |
| 56 | + $cache = yarn cache dir |
| 57 | + } else { |
| 58 | + $cache = npm config get cache |
| 59 | + } |
| 60 | + "NODE_CACHE=$cache" | Out-File $env:GITHUB_ENV -Append |
| 61 | +
|
| 62 | + # Optional sanity check (recommended while debugging) |
| 63 | + - name: Debug cache env |
| 64 | + run: | |
| 65 | + echo "ARCH=$ARCH" |
| 66 | + echo "NODE_CACHE=$NODE_CACHE" |
22 | 67 |
|
23 | 68 | # Restore Node cache (mirrors Restore Go cache) |
24 | 69 | - name: Restore Node cache |
|
33 | 78 |
|
34 | 79 | - name: Build |
35 | 80 | run: npm run build --if-present |
36 | | - |
|
0 commit comments