Interview Prep/GitHub Actions/Contexts, Expressions, Env & Outputs

Why might `github.sha` in a PR workflow not match any commit you pushed?

IntermediateConceptContexts, Expressions, Env & Outputs
Answer

For pull_request, GitHub tests a synthetic merge commit of the PR head into the base (refs/pull/N/merge). Its SHA exists only on GitHub. Tagging images with github.sha in PRs therefore produces tags nobody can trace to a branch commit. Use github.event.pull_request.head.sha for traceable tags and status reporting, and keep the merge ref for testing (it catches semantic conflicts with main).

All GitHub Actions questions Roadmap: GitHub Actions

More on Contexts, Expressions, Env & Outputs