Skip to content

Commit 2be4468

Browse files
committed
ci: conditionally enable setup-node cache when lockfile present
1 parent e5a9e43 commit 2be4468

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

.github/workflows/deploy.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,19 @@ jobs:
2121
- name: Checkout
2222
uses: actions/checkout@v4
2323

24-
- name: Setup Node.js
24+
# Use cache only when a lockfile exists; otherwise setup without cache
25+
- name: Setup Node.js (cached)
26+
if: ${{ hashFiles('**/package-lock.json') != '' || hashFiles('**/npm-shrinkwrap.json') != '' || hashFiles('**/yarn.lock') != '' }}
2527
uses: actions/setup-node@v4
2628
with:
2729
node-version: '18'
2830
cache: 'npm'
31+
32+
- name: Setup Node.js (no cache)
33+
if: ${{ hashFiles('**/package-lock.json') == '' && hashFiles('**/npm-shrinkwrap.json') == '' && hashFiles('**/yarn.lock') == '' }}
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: '18'
2937

3038
- name: Install dependencies
3139
run: |

0 commit comments

Comments
 (0)