@@ -26,19 +26,20 @@ jobs:
26
26
with :
27
27
node-version-file : " .nvmrc"
28
28
29
+ # https://github.com/actions/cache/blob/main/examples.md#node---npm
30
+ - name : Get npm cache directory
31
+ id : npm-cache-dir
32
+ shell : bash
33
+ run : echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
34
+
29
35
- name : Cache node modules
30
36
uses : actions/cache@v4
31
- env :
32
- cache-name : cache-node-modules
37
+ id : npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
33
38
with :
34
- path : |
35
- ~/.npm
36
- **/node_modules
37
- key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
39
+ path : ${{ steps.npm-cache-dir.outputs.dir }}
40
+ key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
38
41
restore-keys : |
39
- ${{ runner.os }}-build-${{ env.cache-name }}-
40
- ${{ runner.os }}-build-
41
- ${{ runner.os }}-
42
+ ${{ runner.os }}-node-
42
43
43
44
- name : Install deps
44
45
run : npm ci --audit=false
@@ -75,19 +76,20 @@ jobs:
75
76
with :
76
77
node-version-file : " .nvmrc"
77
78
79
+ # https://github.com/actions/cache/blob/main/examples.md#node---npm
80
+ - name : Get npm cache directory
81
+ id : npm-cache-dir
82
+ shell : bash
83
+ run : echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
84
+
78
85
- name : Cache node modules
79
86
uses : actions/cache@v4
80
- env :
81
- cache-name : cache-node-modules
87
+ id : npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
82
88
with :
83
- path : |
84
- ~/.npm
85
- **/node_modules
86
- key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
89
+ path : ${{ steps.npm-cache-dir.outputs.dir }}
90
+ key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
87
91
restore-keys : |
88
- ${{ runner.os }}-build-${{ env.cache-name }}-
89
- ${{ runner.os }}-build-
90
- ${{ runner.os }}-
92
+ ${{ runner.os }}-node-
91
93
92
94
- name : Install deps
93
95
run : npm ci --audit=false
@@ -157,19 +159,20 @@ jobs:
157
159
with :
158
160
node-version-file : " .nvmrc"
159
161
162
+ # https://github.com/actions/cache/blob/main/examples.md#node---npm
163
+ - name : Get npm cache directory
164
+ id : npm-cache-dir
165
+ shell : bash
166
+ run : echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
167
+
160
168
- name : Cache node modules
161
169
uses : actions/cache@v4
162
- env :
163
- cache-name : cache-node-modules
170
+ id : npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
164
171
with :
165
- path : |
166
- ~/.npm
167
- **/node_modules
168
- key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
172
+ path : ${{ steps.npm-cache-dir.outputs.dir }}
173
+ key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
169
174
restore-keys : |
170
- ${{ runner.os }}-build-${{ env.cache-name }}-
171
- ${{ runner.os }}-build-
172
- ${{ runner.os }}-
175
+ ${{ runner.os }}-node-
173
176
174
177
- name : Install deps
175
178
run : npm ci --audit=false
@@ -220,19 +223,20 @@ jobs:
220
223
with :
221
224
node-version-file : " .nvmrc"
222
225
226
+ # https://github.com/actions/cache/blob/main/examples.md#node---npm
227
+ - name : Get npm cache directory
228
+ id : npm-cache-dir
229
+ shell : bash
230
+ run : echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
231
+
223
232
- name : Cache node modules
224
233
uses : actions/cache@v4
225
- env :
226
- cache-name : cache-node-modules
234
+ id : npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
227
235
with :
228
- path : |
229
- ~/.npm
230
- **/node_modules
231
- key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
236
+ path : ${{ steps.npm-cache-dir.outputs.dir }}
237
+ key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
232
238
restore-keys : |
233
- ${{ runner.os }}-build-${{ env.cache-name }}-
234
- ${{ runner.os }}-build-
235
- ${{ runner.os }}-
239
+ ${{ runner.os }}-node-
236
240
237
241
- name : Install deps
238
242
run : npm ci --audit=false
0 commit comments