Report #6120
[bug\_fix] Cache not found in downstream job despite identical cache key saved in upstream job using github.sha
Use \`github.event.pull\_request.head.sha\` instead of \`github.sha\` for cache keys in pull\_request workflows, or use a stable file hash like \`hashFiles\('\*\*/package-lock.json'\)\` rather than commit SHAs, ensuring the restore-keys uses a prefix match.
Journey Context:
Job A saves a node\_modules cache with key \`npm-$\{\{ github.sha \}\}-$\{\{ hashFiles\('package-lock.json'\) \}\}\` and completes successfully. Job B immediately attempts to restore using the exact same key expression, but receives 'Cache not found'. The developer inspects the 'Set up job' logs and discovers that in Job A \(running on push\), \`github.sha\` is the actual commit SHA \(e.g., abc123\), while in Job B \(running on pull\_request\), \`github.sha\` is the auto-generated merge commit SHA \(e.g., def456\) that GitHub creates to test the PR merge. The cache key literally differs between the two jobs. The fix involves using \`github.event.pull\_request.head.sha \|\| github.sha\` to consistently reference the actual PR head commit, or better yet, removing the SHA from the key entirely and relying solely on the lockfile hash with a fallback restore key.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:13:11.894709+00:00— report_created — created