diff --git a/.github/workflows/node-module-cache-v1.yml b/.github/workflows/node-module-cache-v1.yml index 524f7df..68074a8 100644 --- a/.github/workflows/node-module-cache-v1.yml +++ b/.github/workflows/node-module-cache-v1.yml @@ -21,6 +21,9 @@ jobs: update_cache: runs-on: ${{ inputs.cpu_architecture == 'x86_64' && 'ubuntu-latest' || format('ubuntu-latest-{0}', inputs.cpu_architecture) }} steps: + - name: Deprecated warning + run: echo "::warning::⚠️ deprecated workflow, use node-module-cache-v2.yml instead" + - uses: actions/checkout@v4 - name: Use Node.js version from package.json diff --git a/.github/workflows/node-module-cache-v2.yml b/.github/workflows/node-module-cache-v2.yml new file mode 100644 index 0000000..09d0cc6 --- /dev/null +++ b/.github/workflows/node-module-cache-v2.yml @@ -0,0 +1,46 @@ +--- +name: Update node_modules cache + +on: + workflow_call: + inputs: + use_legacy_peer_deps: + type: boolean + default: false + description: Enable --legacy-peer-deps option + use_ignore_scripts: + type: boolean + default: false + description: Enable --ignore-scripts option + cpu_architectures: + type: string + description: Array of architectures to run on (e.g., '["x86_64", "arm64"]') + +jobs: + update_cache: + strategy: + matrix: + cpu_architecture: ${{ fromJSON(inputs.cpu_architectures) }} + + runs-on: ${{ matrix.cpu_architecture == 'x86_64' && 'ubuntu-latest' || 'ubuntu-latest-arm64' }} + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js version from package.json + uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + + - name: Set authToken for npm + run: | + npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} + + - name: Npm install + run: npm ci ${{ inputs.use_legacy_peer_deps && '--legacy-peer-deps' || ''}} ${{ inputs.use_ignore_scripts && '--ignore-scripts' || ''}} + + - name: Save cache + uses: actions/cache/save@v4 + with: + path: "**/node_modules" + key: ${{ runner.os }}-${{ runner.arch }}-npm-${{ hashFiles('package-lock.json') }}