@@ -26,19 +26,20 @@ jobs:
2626 with :
2727 node-version-file : " .nvmrc"
2828
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+
2935 - name : Cache node modules
3036 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'
3338 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') }}
3841 restore-keys : |
39- ${{ runner.os }}-build-${{ env.cache-name }}-
40- ${{ runner.os }}-build-
41- ${{ runner.os }}-
42+ ${{ runner.os }}-node-
4243
4344 - name : Install deps
4445 run : npm ci --audit=false
@@ -75,19 +76,20 @@ jobs:
7576 with :
7677 node-version-file : " .nvmrc"
7778
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+
7885 - name : Cache node modules
7986 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'
8288 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') }}
8791 restore-keys : |
88- ${{ runner.os }}-build-${{ env.cache-name }}-
89- ${{ runner.os }}-build-
90- ${{ runner.os }}-
92+ ${{ runner.os }}-node-
9193
9294 - name : Install deps
9395 run : npm ci --audit=false
@@ -157,19 +159,20 @@ jobs:
157159 with :
158160 node-version-file : " .nvmrc"
159161
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+
160168 - name : Cache node modules
161169 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'
164171 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') }}
169174 restore-keys : |
170- ${{ runner.os }}-build-${{ env.cache-name }}-
171- ${{ runner.os }}-build-
172- ${{ runner.os }}-
175+ ${{ runner.os }}-node-
173176
174177 - name : Install deps
175178 run : npm ci --audit=false
@@ -220,19 +223,20 @@ jobs:
220223 with :
221224 node-version-file : " .nvmrc"
222225
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+
223232 - name : Cache node modules
224233 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'
227235 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') }}
232238 restore-keys : |
233- ${{ runner.os }}-build-${{ env.cache-name }}-
234- ${{ runner.os }}-build-
235- ${{ runner.os }}-
239+ ${{ runner.os }}-node-
236240
237241 - name : Install deps
238242 run : npm ci --audit=false
0 commit comments