Skip to content

Commit 72e1b8c

Browse files
authored
[GHA] Expands caching node_modules (#29176)
* [Caching] Use cache for preview step as well * Update wording and remove sync * remove sync
1 parent a1752ff commit 72e1b8c

File tree

1 file changed

+42
-10
lines changed

1 file changed

+42
-10
lines changed

.github/workflows/ci.yml

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,16 @@ jobs:
4545
exit 1
4646
fi
4747
48-
- run: npm ci
48+
- name: Restore node_modules (cache hit)
49+
id: node-modules-cache
50+
uses: actions/cache@v5
51+
with:
52+
path: node_modules
53+
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
54+
55+
- name: Install node_modules (cache miss)
56+
run: npm ci
57+
if: steps.node-modules-cache.outputs.cache-hit != 'true'
4958

5059
- run: npx tsx bin/post-codeowners-comment/index.ts
5160
continue-on-error: true
@@ -132,18 +141,14 @@ jobs:
132141
exit 1
133142
fi
134143
135-
- name: Cache node_modules
144+
- name: Restore node_modules (cache hit)
136145
id: node-modules-cache
137146
uses: actions/cache@v5
138147
with:
139148
path: node_modules
140149
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
141150

142-
- name: Run sync (if cache hit)
143-
run: npm run sync
144-
if: steps.node-modules-cache.outputs.cache-hit == 'true'
145-
146-
- name: Node install (cache miss)
151+
- name: Install node_modules (cache miss)
147152
run: npm ci
148153
if: steps.node-modules-cache.outputs.cache-hit != 'true'
149154

@@ -216,7 +221,16 @@ jobs:
216221
node-version: 22.x
217222
cache: npm
218223

219-
- run: npm ci
224+
- name: Restore node_modules (cache hit)
225+
id: node-modules-cache
226+
uses: actions/cache@v5
227+
with:
228+
path: node_modules
229+
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
230+
231+
- name: Install node_modules (cache miss)
232+
run: npm ci
233+
if: steps.node-modules-cache.outputs.cache-hit != 'true'
220234

221235
- uses: actions/download-artifact@v8
222236
with:
@@ -262,7 +276,16 @@ jobs:
262276
node-version: 22.x
263277
cache: npm
264278

265-
- run: npm ci
279+
- name: Restore node_modules (cache hit)
280+
id: node-modules-cache
281+
uses: actions/cache@v5
282+
with:
283+
path: node_modules
284+
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
285+
286+
- name: Install node_modules (cache miss)
287+
run: npm ci
288+
if: steps.node-modules-cache.outputs.cache-hit != 'true'
266289

267290
- name: Post PR CI failure comment
268291
continue-on-error: true
@@ -288,7 +311,16 @@ jobs:
288311
node-version: 22.x
289312
cache: npm
290313

291-
- run: npm ci
314+
- name: Restore node_modules (cache hit)
315+
id: node-modules-cache
316+
uses: actions/cache@v5
317+
with:
318+
path: node_modules
319+
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
320+
321+
- name: Install node_modules (cache miss)
322+
run: npm ci
323+
if: steps.node-modules-cache.outputs.cache-hit != 'true'
292324

293325
- uses: actions/download-artifact@v8
294326
with:

0 commit comments

Comments
 (0)