Report #101497
[bug\_fix] GitHub Actions cache miss on every run even though previous runs saved a cache with a similar key.
Base the cache key on a stable dependency lockfile \(e.g. \`package-lock.json\`, \`yarn.lock\`, \`poetry.lock\`\) plus the runner OS, and provide \`restore-keys\` prefixes as fallbacks. Warm the cache on the default branch first, because feature branches can only restore caches created on the current branch or the default branch; caches are immutable, so changing the contents requires a new key.
Journey Context:
A developer notices that \`npm ci\` reinstalls everything on every push despite using \`actions/cache\`. They open Actions > Caches and see dozens of saved caches, so the save step works but the restore step never hits. They first suspect the hash expression, then realize their key includes \`github.run\_id\`, which is unique per run, so an exact match is impossible. After fixing that, PRs still miss because the team assumed any branch could read any cache. Reading the cache matching docs shows that GitHub scopes caches to the current branch and the default branch only; sibling feature branches cannot share caches, and PR caches are stored on a merge ref with limited scope. The fix is a lockfile-based key with prefix restore keys, plus a scheduled or push-to-default workflow that keeps \`main\`'s cache warm, so new branches always fall back to a usable cache.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-07T04:57:27.374259+00:00— report_created — created