-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
51 lines (48 loc) · 1.55 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
45
46
47
48
49
50
51
name: Node.js with node_modules cache
inputs:
version:
description: Node.js version.
default:
version-file:
description: Node.js version from file. Used in place of `version`.
default:
node-modules-path:
description: Path to node_modules.
default: node_modules
additional-cache-path:
description: Optional path(s) to be included alongside node_modules.
default:
package-lock-path:
description: Path to package-lock.json.
default: package-lock.json
cache-key-suffix:
description: Optional cache key suffix.
default:
outputs:
cache-hit:
description: Boolean value to indicate cache hit.
value: ${{ steps.cache-nodemodules.outputs.cache-hit }}
runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.version }}
node-version-file: ${{ inputs.version-file }}
- name: Construct cache key
id: cache-key
run: |
versionNode=$(node --version)
versionNpm=$(npm --version)
cacheKeyRoot="nodemodules-${{ runner.os }}${{ inputs.cache-key-suffix && format('-{0}',inputs.cache-key-suffix) }}-${versionNode#v}-$versionNpm-"
echo "hashed=${cacheKeyRoot}${{ hashFiles(inputs.package-lock-path) }}" >>"$GITHUB_OUTPUT"
shell: bash
- name: Setup node_modules cache
id: cache-nodemodules
uses: actions/cache@v4
with:
key: ${{ steps.cache-key.outputs.hashed }}
path: |
${{ inputs.node-modules-path }}
${{ inputs.additional-cache-path }}