-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
44 lines (41 loc) · 1.53 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: NodeJS with cache
author: Draftea
description: Setup requested NodeJS version with managed modules caching.
inputs:
node-version:
description: Desired NodeJS version.
default:
working-directory:
description: path where the npm install command is run.
default:
cache-key-suffix:
description: Optional cache key suffix.
default:
outputs:
cache-path:
description: NodeJS modules cache path.
value: ${{ steps.nodejs-env.outputs.module-cache-path }}
cache-key:
description: Cache key holding module cache paths.
value: ${{ steps.nodejs-env.outputs.cache-key }}
runs:
using: composite
steps:
- name: ⚙️ Setup NodeJS
uses: useblacksmith/setup-node@v5
with:
node-version: ${{ inputs.node-version }}
- name: Determine node_modules paths and construct cache key
id: nodejs-env
run: |
echo "cache-path=${{ inputs.working-directory }}/node_modules" >>"$GITHUB_OUTPUT"
cacheKeyRoot="${{ runner.os }}-nodejs${{ inputs.cache-key-suffix && format('-{0}',inputs.cache-key-suffix) }}-"
echo "cache-key-restore=$cacheKeyRoot" >>"$GITHUB_OUTPUT"
echo "cache-key=${cacheKeyRoot}${{ hashFiles(format('{0}/{1}', inputs.working-directory, 'package-lock.json')) }}" >>"$GITHUB_OUTPUT"
shell: bash
- name: Setup cache
uses: useblacksmith/cache@v5
with:
path: ${{ steps.nodejs-env.outputs.cache-path }}
key: ${{ steps.nodejs-env.outputs.cache-key }}
restore-keys: ${{ steps.nodejs-env.outputs.cache-key-restore }}