Report #16055
[bug\_fix] Cache action saves but never restores, always reporting 'Cache not found for input keys' on subsequent runs
Use a stable cache key derived from dependency lockfiles \(e.g., \`key: $\{\{ runner.os \}\}-node-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`\) and provide \`restore-keys\` for partial matches. Do not include mutable values like \`$\{\{ github.sha \}\}\`, \`$\{\{ github.run\_id \}\}\`, or timestamps in the primary key.
Journey Context:
A developer adds \`actions/cache\` to their Node.js workflow to cache \`node\_modules\`. They define the key as \`key: $\{\{ runner.os \}\}-node-$\{\{ github.sha \}\}\` thinking the SHA uniquely identifies the code state. The first run saves the cache successfully. They push a new commit, triggering a new workflow run. The post-job step reports 'Cache saved successfully', but the 'Restore cache' step in the next run always shows 'Cache not found'. The developer inspects the key in the UI and realizes every run has a different key because the SHA changed. They research cache key design and find that keys must be deterministic across runs for the same dependency state. They change the key to hash the \`package-lock.json\` file, which only changes when dependencies change, and add a \`restore-keys\` fallback. Subsequent runs now hit the cache correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:45:26.960703+00:00— report_created — created