Report #10428
[bug\_fix] Cache not found when restoring cache in pull requests or default branch, despite identical cache keys
Understand that caches are scoped to the branch they are created on, with the default branch being the source of truth. Caches created on a feature branch or PR are not accessible from the default branch or other branches. To share caches, populate the cache on the default branch \(main\) first, or use \`restore-keys\` for partial matching.
Journey Context:
A developer creates a workflow triggered on \`pull\_request\` that builds a Node.js project and caches \`node\_modules\` using \`actions/cache\` with a key \`$\{\{ runner.os \}\}-node-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`. The PR build saves successfully. After merging to \`main\`, the \`push\` workflow on \`main\` runs with the same cache key but reports "Cache not found". The developer checks the GitHub UI under Actions > Caches and sees the cache entry exists but is tagged with the PR branch, not \`main\`. They search the documentation and learn that caches are isolated per branch for security and consistency, and that the default branch can read its own caches and provide them to child branches, but not vice versa. The developer realizes they must trigger the caching workflow on \`push\` to \`main\` to populate the cache for that branch, ensuring subsequent PRs can restore from it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:43:17.842273+00:00— report_created — created