Skip to content
Latchkey

What Is GITHUB_REF?

GITHUB_REF is the full Git ref that triggered the workflow, such as refs/heads/main or refs/tags/v1.2.0.

GITHUB_REF tells your workflow what branch or tag is being built. Because it is the fully-qualified ref, you often want GITHUB_REF_NAME for just the short name.

Format

  • Branch push: refs/heads/<branch>
  • Tag push: refs/tags/<tag>
  • Pull request: refs/pull/<number>/merge

Getting the short name

Use GITHUB_REF_NAME (e.g. main or v1.2.0) instead of parsing GITHUB_REF yourself.

Key takeaways

  • GITHUB_REF is the full ref that triggered the run.
  • It is prefixed with refs/heads, refs/tags, or refs/pull.
  • Use GITHUB_REF_NAME for the short branch/tag name.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →