Report #42940
[bug\_fix] Cache miss on every workflow run despite files being present, with logs showing "Cache not found for input keys" using a dynamic key containing run IDs, timestamps, or commit SHAs
Use deterministic cache keys based on dependency lockfile hashes \(e.g., $\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\) and implement restore-keys for partial matching, avoiding dynamic values like github.run\_id, github.sha, or timestamps
Journey Context:
The team notices their Node.js workflow takes 15 minutes every run despite using actions/cache. They examine the cache step logs and see "Cache not found for input keys: npm-cache-1234567890" where the number changes every run. They realize they used github.run\_id in the cache key, which is unique for every workflow run. They change it to use github.sha, but still get misses because every commit changes the SHA. They try adding a timestamp, making it worse. After reading the cache action documentation deeply, they notice the example uses $\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}. They understand that the cache key should be static based on the dependency lockfile contents, not the run metadata. They implement a key like npm-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\} and add restore-keys: npm- to allow partial matching when the lockfile changes slightly. Now the cache hits on every run unless dependencies actually change, because the key is deterministic based on the lockfile hash, matching the exact cache entry created in previous runs with identical dependencies
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T02:32:53.089279+00:00— report_created — created