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

What are the `github.ref`, `github.ref_name`, `github.head_ref` and `github.base_ref` values for a PR from `feature/x` into `main`?

IntermediateConceptContexts, Expressions, Env & Outputs
Answer

For pull_request:

  • github.ref: refs/pull/42/merge
  • github.ref_name: 42/merge
  • github.head_ref: feature/x
  • github.base_ref: main
  • github.sha: the test merge commit, not the PR head; the head is github.event.pull_request.head.sha

For push to main: ref is refs/heads/main, ref_name is main, and head_ref/base_ref are empty.

All GitHub Actions questions Roadmap: GitHub Actions

More on Contexts, Expressions, Env & Outputs