Collection of reusable GitHub Actions
- Install packages using
npm
,yarn
orpnpm
- Caches whole
node_modules
directory - Skips installation step when lockfile cache is hit
- Automatically appends OS and Node version to the
cache-key
working-directory
– the default working directorycache-key
– an explicit key for restoring and saving the cache
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: avocadowastaken/actions/npm/install@v2
- run: npm test
Passing cache-key
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [14, 16, 18]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- uses: avocadowastaken/actions/npm/install@v2
with:
cache-key: ${{ github.sha }}-
- run: npm test
- Disables
autocrlf
ingit config
- Checks out repository
- Downloads required Node version (see
node-version
option) - Installs packages (see avocadowastaken/actions/npm/install)
working-directory
– the default working directorynode-version
– Node version specifiercache-key
– an explicit key for restoring and saving the cache
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [14, 16, 18]
os: [ubuntu-latest, windows-latest]
steps:
- uses: avocadowastaken/actions/setup-node-repo@v2
with:
node-version: ${{ matrix.node }}
- run: npm test
Passing cache-key
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [14, 16, 18]
os: [ubuntu-latest, windows-latest]
steps:
- uses: avocadowastaken/actions/setup-node-repo@v2
with:
cache-key: ${{ github.sha }}-
node-version: ${{ matrix.node }}
- run: npm test