Report #11358
[bug\_fix] Cache not found for input keys despite cache existing in GitHub Actions cache
Ensure the \`restore-keys\` input includes a prefix fallback \(e.g., \`$\{\{ runner.os \}\}-build-\`\) so partial matches succeed, and avoid using dynamic values like \`$\{\{ github.sha \}\}\` or \`$\{\{ github.run\_id \}\}\` in the primary \`key\` unless you intend the cache to be immutable per run. The primary key must match exactly; restore-keys provides the prefix matching logic.
Journey Context:
A developer configures \`actions/cache\` for Node modules using a key \`$\{\{ runner.os \}\}-$\{\{ github.sha \}\}\`. They notice that every run says 'Cache not found' even though the previous run successfully saved a cache. They inspect the cache list in the GitHub UI and see dozens of entries, one per SHA. They realize that because the SHA changes every commit, the exact key lookup fails. They read the documentation on 'Matching a cache key' and learn that \`restore-keys\` supports prefix matching, but the primary \`key\` does not. They change the key to \`$\{\{ runner.os \}\}-node-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\` and add \`restore-keys: $\{\{ runner.os \}\}-node-\`, which allows the cache to hit on any lockfile change or partial match, cutting build time by 80%.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T13:11:22.401964+00:00— report_created — created