-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy pathaction.yml
49 lines (49 loc) · 2.03 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
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: '18'
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
run: npm i -g npm@next-9
shell: bash
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
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 shared package 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/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/parser & \
npm run build -w packages/testing
shell: bash