actions / setup-node

Set up your GitHub Actions workflow with a specific version of node.js
MIT License
3.85k stars 1.26k forks source link

Add fallback cache keys #1120

Open hyrious opened 1 month ago

hyrious commented 1 month ago

Description:

Currently the cache key is always node-cache-{platform}-{packageManager}-{fileHash(lockfile)}, which means the cache is invalid if any one dependency changed. I want to achieve something like this restore-keys:

restore-keys: |
  npm-feature-${{ hashFiles('package-lock.json') }}
  npm-feature-
  npm-

Justification:

It would be very helpful if the same cache can be reused across many places even if their package.json has changed.

Are you willing to submit a PR?

I noticed that Yarn berry already has some logic about this, can we expand that use cases to all package managers?

priyagupta108 commented 1 month ago

Hi @hyrious 👋, Thank you for the feature request. We'll investigate it and get back to you as soon as we have updates.