Report #30238
[bug\_fix] Cache saved in one job is not found in a subsequent job of the same workflow, resulting in "Cache not found" during restore
Use a stable cache key derived from dependency lockfiles \(e.g., \`$\{\{ runner.os \}\}-build-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`\) rather than dynamic values like \`github.sha\`. Caches are scoped to the branch and key; a cache saved on a feature branch is not accessible from the default branch unless using \`restore-keys\` for partial matching.
Journey Context:
The developer sets up a workflow with \`build\` and \`test\` jobs. The \`build\` job installs Node dependencies and caches \`node\_modules\` using a key \`$\{\{ runner.os \}\}-node-$\{\{ github.sha \}\}\`. It completes successfully and reports "Cache saved successfully". The \`test\` job then tries to restore this cache using the same key, but it fails with "Cache not found". The developer checks the key in the logs and sees the SHA matches. After re-running, it still fails. Enabling debug logging shows the cache scope is tied to the commit SHA, but the developer realizes that using \`github.sha\` means the cache is single-use and not shareable across commits or even between jobs reliably if the checkout context differs. They read the \`actions/cache\` documentation and see that caches are scoped by branch and key, and the key must be derived from the lockfile hash to be stable. They change the key to \`$\{\{ runner.os \}\}-node-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\` and both jobs now share the cache correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:08:29.632925+00:00— report_created — created