Skip to content

Commit 472dc43

Browse files
committed
ci(actions): 👷 cache node_modules
1 parent 1478d0f commit 472dc43

File tree

1 file changed

+16
-40
lines changed

1 file changed

+16
-40
lines changed

.github/workflows/main.yml

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,15 @@ jobs:
2222
with:
2323
node-version-file: .nvmrc
2424

25-
- name: Get yarn cache directory path
26-
id: yarn-cache-dir-path
27-
run: echo "::set-output name=dir::$(yarn cache dir)"
28-
2925
- name: Cache node_modules
3026
uses: actions/cache@v3
31-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
27+
id: cache-node-modules # use this to check for `cache-hit` (`steps.cache-node-modules.outputs.cache-hit != 'true'`)
3228
with:
33-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
34-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
35-
restore-keys: |
36-
${{ runner.os }}-yarn-
29+
path: node_modules
30+
key: modules-${{ hashFiles('yarn-lock.json') }}
3731

3832
- name: Install Dependencies
39-
if: steps.yarn-cache.outputs.cache-hit != 'true'
33+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
4034
run: yarn --frozen-lockfile
4135

4236
lint:
@@ -53,21 +47,15 @@ jobs:
5347
with:
5448
node-version-file: .nvmrc
5549

56-
- name: Get yarn cache directory path
57-
id: yarn-cache-dir-path
58-
run: echo "::set-output name=dir::$(yarn cache dir)"
59-
6050
- name: Cache node_modules
6151
uses: actions/cache@v3
62-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
52+
id: cache-node-modules # use this to check for `cache-hit` (`steps.cache-node-modules.outputs.cache-hit != 'true'`)
6353
with:
64-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
65-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
66-
restore-keys: |
67-
${{ runner.os }}-yarn-
54+
path: node_modules
55+
key: modules-${{ hashFiles('yarn-lock.json') }}
6856

6957
- name: Install Dependencies
70-
if: steps.yarn-cache.outputs.cache-hit != 'true'
58+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
7159
run: yarn --frozen-lockfile
7260

7361
- name: Lint
@@ -87,21 +75,15 @@ jobs:
8775
with:
8876
node-version-file: .nvmrc
8977

90-
- name: Get yarn cache directory path
91-
id: yarn-cache-dir-path
92-
run: echo "::set-output name=dir::$(yarn cache dir)"
93-
9478
- name: Cache node_modules
9579
uses: actions/cache@v3
96-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
80+
id: cache-node-modules # use this to check for `cache-hit` (`steps.cache-node-modules.outputs.cache-hit != 'true'`)
9781
with:
98-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
99-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
100-
restore-keys: |
101-
${{ runner.os }}-yarn-
82+
path: node_modules
83+
key: modules-${{ hashFiles('yarn-lock.json') }}
10284

10385
- name: Install Dependencies
104-
if: steps.yarn-cache.outputs.cache-hit != 'true'
86+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
10587
run: yarn --frozen-lockfile
10688

10789
- name: Built
@@ -125,21 +107,15 @@ jobs:
125107
with:
126108
node-version-file: .nvmrc
127109

128-
- name: Get yarn cache directory path
129-
id: yarn-cache-dir-path
130-
run: echo "::set-output name=dir::$(yarn cache dir)"
131-
132110
- name: Cache node_modules
133111
uses: actions/cache@v3
134-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
112+
id: cache-node-modules # use this to check for `cache-hit` (`steps.cache-node-modules.outputs.cache-hit != 'true'`)
135113
with:
136-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
137-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
138-
restore-keys: |
139-
${{ runner.os }}-yarn-
114+
path: node_modules
115+
key: modules-${{ hashFiles('yarn-lock.json') }}
140116

141117
- name: Install Dependencies
142-
if: steps.yarn-cache.outputs.cache-hit != 'true'
118+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
143119
run: yarn --frozen-lockfile
144120

145121
- name: Test

0 commit comments

Comments
 (0)