Report #52494
[bug\_fix] Cache not found or cache miss between branches despite identical lockfile
Add a \`restore-keys\` fallback list to \`actions/cache\` that uses a prefix key without the branch name or lockfile hash. Caches are branch-scoped by default; a cache created on main is not accessible to a PR branch unless the key matches exactly or a restore-key prefix allows cross-branch restoration.
Journey Context:
Developer sets up \`actions/cache@v3\` for npm, using a key \`$\{\{ runner.os \}\}-node-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`. The first run on main populates the cache. A contributor opens a PR from a fork. The workflow runs but shows 'Cache not found'. Developer checks the Actions tab for the main branch, confirms the cache exists with the exact same hash. They try re-running the job, still a miss. They inspect the cache API via \`gh api repos/\{owner\}/\{repo\}/actions/caches\` and notice the cache scope is 'refs/heads/main', not accessible to 'refs/pull/123/merge'. Reading the documentation on cache key matching, they realize restore-keys with a prefix \`$\{\{ runner.os \}\}-node-\` would allow the PR to restore the main branch's cache as a fallback. They add the restore-keys list, the PR re-runs, and immediately restores the cache from main, 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-19T18:36:19.380415+00:00— report_created — created