Some checks failed
Run mypy_primer on push / Run mypy_primer on push (push) Has been cancelled
Validation / Typecheck (push) Has been cancelled
Validation / Style (push) Has been cancelled
Validation / Test macos-latest (push) Has been cancelled
Validation / Test ubuntu-latest (push) Has been cancelled
Validation / Test windows-latest (push) Has been cancelled
Validation / Build (push) Has been cancelled
Validation / Required (push) Has been cancelled
50 lines
1.9 KiB
YAML
50 lines
1.9 KiB
YAML
name: Cache npm download directory
|
|
description: Cache npm's download cache directory (npm config get cache) using actions/cache
|
|
|
|
inputs:
|
|
cache-dependency-path:
|
|
description: Glob(s) passed to hashFiles to generate the cache key
|
|
default: '**/package-lock.json'
|
|
required: false
|
|
include-npmrc-hash:
|
|
description: Include hashFiles('**/.npmrc') in the key (useful when registry settings affect cache safety)
|
|
default: 'false'
|
|
required: false
|
|
key-prefix:
|
|
description: Prefix for the generated key
|
|
default: 'node'
|
|
required: false
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Get npm cache directory (non-Windows)
|
|
id: npm-cache-dir-bash
|
|
if: runner.os != 'Windows'
|
|
shell: bash
|
|
run: echo "dir=$(npm config get cache)" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Get npm cache directory (Windows)
|
|
id: npm-cache-dir-pwsh
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: |
|
|
$dir = npm config get cache
|
|
"dir=$dir" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
|
|
|
|
- name: Cache npm cache directory (with .npmrc)
|
|
if: inputs.include-npmrc-hash == 'true'
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ${{ steps.npm-cache-dir-bash.outputs.dir || steps.npm-cache-dir-pwsh.outputs.dir }}
|
|
key: ${{ runner.os }}-${{ inputs.key-prefix }}-${{ hashFiles('**/.npmrc') }}-${{ hashFiles(inputs.cache-dependency-path) }}
|
|
restore-keys: ${{ runner.os }}-${{ inputs.key-prefix }}-${{ hashFiles('**/.npmrc') }}-
|
|
|
|
- name: Cache npm cache directory
|
|
if: inputs.include-npmrc-hash != 'true'
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ${{ steps.npm-cache-dir-bash.outputs.dir || steps.npm-cache-dir-pwsh.outputs.dir }}
|
|
key: ${{ runner.os }}-${{ inputs.key-prefix }}-${{ hashFiles(inputs.cache-dependency-path) }}
|
|
restore-keys: ${{ runner.os }}-${{ inputs.key-prefix }}-
|