$ ./guess_the_languageDevOps
DevOps · medium · #273

With this key, what makes the job save a fresh cache entry?

- uses: actions/cache@v4
  with:
    path: ~/.npm
    key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
  1. Any push to the main branch
  2. Any new commit to the repo
  3. A version bump in package.json
  4. A change to the lockfile
hashFiles fingerprints the lockfile, so the key, and therefore a new cache, changes only when the resolved dependencies do; otherwise the existing entry is restored.
Play DevOps ▸