File tree Expand file tree Collapse file tree 1 file changed +27
-9
lines changed
Expand file tree Collapse file tree 1 file changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -14,19 +14,37 @@ jobs:
1414 - name : Checkout repository
1515 uses : actions/checkout@v4
1616
17- - name : Set up Node.js
17+ - name : Find lockfiles (for caching)
18+ id : find-lockfiles
19+ run : |
20+ echo "Searching for lockfiles..."
21+ files=$(find . -type f \( -name 'package-lock.json' -o -name 'pnpm-lock.yaml' -o -name 'yarn.lock' -o -name 'npm-shrinkwrap.json' \) -print | sed 's|^\./||')
22+ if [ -n "$files" ]; then
23+ echo "Found lockfiles:"
24+ printf "%s\n" "$files"
25+ # Write a multiline output for cache-dependency-path (newline-separated)
26+ echo "lockfile-paths<<EOF" >> $GITHUB_OUTPUT
27+ printf "%s\n" "$files" >> $GITHUB_OUTPUT
28+ echo "EOF" >> $GITHUB_OUTPUT
29+ else
30+ echo "No lockfiles found"
31+ # set empty output
32+ echo "lockfile-paths=" >> $GITHUB_OUTPUT
33+ fi
34+
35+ - name : Set up Node.js (with cache)
36+ if : ${{ steps.find-lockfiles.outputs.lockfile-paths != '' }}
1837 uses : actions/setup-node@v4
1938 with :
2039 node-version : ' 20'
2140 cache : ' npm'
22- # If your repo is a monorepo or lockfiles live in subdirectories, list them here
23- cache-dependency-path : |
24- package-lock.json
25- **/package-lock.json
26- pnpm-lock.yaml
27- **/pnpm-lock.yaml
28- yarn.lock
29- **/yarn.lock
41+ cache-dependency-path : ${{ steps.find-lockfiles.outputs.lockfile-paths }}
42+
43+ - name : Set up Node.js (no cache)
44+ if : ${{ steps.find-lockfiles.outputs.lockfile-paths == '' }}
45+ uses : actions/setup-node@v4
46+ with :
47+ node-version : ' 20'
3048
3149 - name : Set up Python
3250 uses : actions/setup-python@v4
You can’t perform that action at this time.
0 commit comments