-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy pathaction.yml
51 lines (51 loc) · 2.2 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: 'Cached Node Modules'
description: 'A simple action to cache node_modules or install them if they are not cached'
inputs:
nodeVersion: # id of input
description: 'Node.js version to use in the cache key'
default: '20'
build:
description: 'Whether to build the packages or not'
default: 'true'
outputs:
cache-hit:
description: "Whether the cache was hit or not"
value: ${{ steps.cache-node-modules.outputs.cache-hit }}
runs:
using: "composite"
steps:
- name: Install npm
# We need to keep this npm version until we drop Node.js 16 support because Node.js 16 doesn't support npm 10
run: npm i -g npm@next-9
shell: bash
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: '**/node_modules'
# Use the combo between node version, name, and SHA-256 hash of the lock file as cache key so that
# if one of them changes the cache is invalidated/discarded
key: ${{ inputs.nodeVersion }}-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
# We can skip the installation if there was a cache hit
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
shell: bash
- name: Build packages
# Regardless of whether the cache was hit or not, we need to build the packages, unless the caller says otherwise
if: inputs.build == 'true'
# We build the commons and jmspath packages first, then the others in parallel to speed up the process
# even though we could just run `npm run build` in the root folder and build them in
# sequence, but still in the correct order.
run: |
npm run build -w packages/commons
npm run build -w packages/jmespath
npm run build -w packages/logger & \
npm run build -w packages/tracer & \
npm run build -w packages/metrics & \
npm run build -w packages/parameters & \
npm run build -w packages/idempotency & \
npm run build -w packages/batch & \
npm run build -w packages/testing & \
npm run build -w packages/parser
shell: bash