Report #73818
[bug\_fix] GitHub Actions cache step reports 'Cache not found' on every run despite successful upload in previous run, resulting in slow builds and dependency re-installation
Add a \`restore-keys\` list to the \`actions/cache\` step with less specific prefixes \(e.g., \`$\{\{ runner.os \}\}-npm-\`\). The root cause is that GitHub cache keys are immutable and require an exact string match; when lock files change slightly, the exact key misses, and without restore-keys, no fallback occurs.
Journey Context:
A developer adds \`actions/cache\` to their Node.js workflow, using a key like \`npm-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`. The first run uploads successfully. They push a commit that updates a single dependency, triggering the workflow again. The Post Cache step shows "Cache not found" for the key. The developer investigates the Actions Cache UI and sees the old cache exists with a different hash. They initially suspect a scope issue \(caches are branch-scoped\) but confirm they are on the same default branch. After reading the cache action documentation, they realize the cache key system requires an exact match and that \`restore-keys\` provides the fallback mechanism. They modify the workflow to include \`restore-keys: \| $\{\{ runner.os \}\}-npm-\`, which allows the workflow to find and restore the previous cache even when the lock file changes, then update the cache with the new key for future runs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T06:30:05.939298+00:00— report_created — created