Report #85582
[bug\_fix] Cache key not found or cache miss when running on pull requests from different branches
Use restore-keys with a prefix match \(e.g., $\{\{ runner.os \}\}-node-\) to fall back to caches from the default branch, or ensure the cache is explicitly saved on the default branch before other branches try to access it.
Journey Context:
A developer configures actions/cache to store node\_modules using a key that hashes the package-lock.json file: "key: $\{\{ runner.os \}\}-node-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}". The workflow runs on the main branch and successfully saves the cache. When a pull request is opened from a feature branch, the workflow runs but reports "Cache not found for input keys" despite the package-lock.json being identical to main. The developer manually queries the GitHub API and confirms the cache entry exists with the exact key. After extensive debugging, they discover that GitHub Actions caches are isolated by branch scope—a cache created on the main branch is not directly accessible to a feature branch unless the feature branch explicitly restores it using restore-keys with a partial match. The developer updates the workflow to include "restore-keys: $\{\{ runner.os \}\}-node-" to match the prefix of the main branch cache. The cache restores successfully on PRs, significantly speeding up the build.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:14:16.798259+00:00— report_created — created