Skip to content

Commit 58c1799

Browse files
committed
use yarn.lock for key
1 parent 2e53992 commit 58c1799

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

.github/workflows/cache.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ jobs:
2222
sparse-checkout-cone-mode: false
2323
sparse-checkout: |
2424
package.json
25-
- name: 📥 Install deps
25+
- id: install
26+
name: 📥 Install deps
2627
run: yarn
2728
env:
2829
HUSKY_SKIP_INSTALL: true
29-
- name: ♻️ Save node_modules
30+
- if: >
31+
steps.install.outcome == 'success'
32+
name: ♻️ Save node_modules
3033
uses: actions/cache/save@v4
3134
with:
3235
path: |
3336
yarn.lock
3437
node_modules
35-
key: ${{ runner.os }}-${{ hashFiles('package.json') }}
38+
key: ${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}

.github/workflows/ci.yml

+19-4
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,32 @@ jobs:
1414
steps:
1515
- name: ⬇️ Checkout repo
1616
uses: actions/checkout@v4
17-
- name: ♻️ Cache node_modules
18-
uses: actions/cache@v4
17+
- id: restore
18+
name: ♻️ Restore node_modules
19+
uses: actions/cache/restore@v4
1920
with:
2021
path: |
2122
yarn.lock
2223
node_modules
23-
key: ${{ runner.os }}-${{ hashFiles('package.json') }}
24-
- name: 📥 Install deps
24+
key: ${{ hashFiles('package.json') }}
25+
restore-keys: ${{ hashFiles('package.json') }}-
26+
27+
- id: install
28+
if: >
29+
steps.restore.outputs.cache-matched-key == ''
30+
name: 📥 Install deps
2531
run: yarn
2632
env:
2733
HUSKY_SKIP_INSTALL: true
34+
- if: >
35+
steps.install.outcome == 'success'
36+
name: ♻️ Save node_modules
37+
uses: actions/cache/save@v4
38+
with:
39+
path: |
40+
yarn.lock
41+
node_modules
42+
key: ${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}
2843
2944
- name: ✍ Lint
3045
run: npm run lint

0 commit comments

Comments
 (0)