Skip to content

Commit 4d87da9

Browse files
committed
feat(workflow/node-module-cache): support multiple cpu arch
1 parent 89cd11f commit 4d87da9

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

.github/workflows/node-module-cache-v1.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
update_cache:
2222
runs-on: ${{ inputs.cpu_architecture == 'x86_64' && 'ubuntu-latest' || format('ubuntu-latest-{0}', inputs.cpu_architecture) }}
2323
steps:
24+
- name: Deprecated warning
25+
run: echo "::warning::⚠️ deprecated workflow, use node-module-cache-v2.yml instead"
26+
2427
- uses: actions/checkout@v4
2528

2629
- name: Use Node.js version from package.json
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: Update node_modules cache
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
use_legacy_peer_deps:
8+
type: boolean
9+
default: false
10+
description: Enable --legacy-peer-deps option
11+
use_ignore_scripts:
12+
type: boolean
13+
default: false
14+
description: Enable --ignore-scripts option
15+
cpu_architectures:
16+
type: string
17+
description: Array of architectures to run on (e.g., '["x86_64", "arm64"]')
18+
19+
jobs:
20+
update_cache:
21+
strategy:
22+
matrix:
23+
cpu_architecture: ${{ fromJSON(inputs.cpu_architectures) }}
24+
25+
runs-on: ${{ matrix.cpu_architecture == 'x86_64' && 'ubuntu-latest' || 'ubuntu-latest-arm64' }}
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Use Node.js version from package.json
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version-file: "package.json"
34+
35+
- name: Set authToken for npm
36+
run: |
37+
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
38+
39+
- name: Npm install
40+
run: npm ci ${{ inputs.use_legacy_peer_deps && '--legacy-peer-deps' || ''}} ${{ inputs.use_ignore_scripts && '--ignore-scripts' || ''}}
41+
42+
- name: Save cache
43+
uses: actions/cache/save@v4
44+
with:
45+
path: "**/node_modules"
46+
key: ${{ runner.os }}-${{ runner.arch }}-npm-${{ hashFiles('package-lock.json') }}

0 commit comments

Comments
 (0)