-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathaction.yml
More file actions
66 lines (59 loc) · 2.44 KB
/
action.yml
File metadata and controls
66 lines (59 loc) · 2.44 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Yarn Install
description: Runs yarn install using caching with monorepo support
inputs:
cache-prefix:
description: The prefix to use for all cache keys to keep different environments separate
required: true
corepack-version:
description: Version of corepack to use. Defaults to latest
default: 'latest'
yarn-install-force:
description: Whether to force the installation of yarn via corepack
default: false
outputs:
cache-hit:
description: Whether the node_modules cache got an exact cache hit
value: ${{ steps.cache-modules.outputs.cache-hit }}
yarn-cache-dir:
description: The location of the global yarn cache
value: ${{ steps.yarn-cache.outputs.dir }}
runs:
using: 'composite'
steps:
# Cache every node_modules folder inside the monorepo
- name: cache all node_modules
id: cache-modules
uses: actions/cache@v4
with:
path: '**/node_modules'
# We use both yarn.lock and package.json as cache keys to ensure that
# changes to local monorepo packages bust the cache.
key: ${{ inputs.cache-prefix }}-node_modules-${{ hashFiles('yarn.lock', '**/package.json') }}
- name: prepare corepack
shell: bash
run: |
if [[ "${{ inputs.yarn-install-force }}" == "true" ]]; then
npm install --force -g corepack@${{ inputs.corepack-version }}
else
npm install -g corepack@${{ inputs.corepack-version }}
fi
corepack enable
# If we get a cache hit for node_modules, there's no need to bring in the global
# yarn cache or run yarn install, as all dependencies will be installed already.
- name: find location of global yarn cache
id: yarn-cache
if: steps.cache-modules.outputs.cache-hit != 'true'
run: echo "dir=$([[ "$(yarn --version)" =~ "1.*" ]] && yarn cache dir || yarn config get cacheFolder)" >> $GITHUB_OUTPUT
shell: bash
- name: cache global yarn cache
uses: actions/cache@v4
if: steps.cache-modules.outputs.cache-hit != 'true'
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ inputs.cache-prefix }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ inputs.cache-prefix }}-yarn-
- name: yarn install
if: steps.cache-modules.outputs.cache-hit != 'true'
run: '[[ "$(yarn --version)" =~ "1.*" ]] && yarn install --frozen-lockfile || yarn install --immutable'
shell: bash