Skip to content
Latchkey

What Is GITHUB_REF_NAME?

GITHUB_REF_NAME is the short, human-friendly name of the branch or tag that triggered the run.

Where GITHUB_REF is the full ref, GITHUB_REF_NAME strips the prefix and gives you just main, feature/login, or v1.2.0 - what you usually want for naming and conditionals.

Common uses

  • Deploy only when the ref name is main
  • Name a release after the tag
  • Slugify the branch for a preview URL

Example

Gate a deploy job on the branch name.

yaml
if: ${{ github.ref_name == 'main' }}

Key takeaways

  • GITHUB_REF_NAME is the short branch/tag name.
  • It drops the refs/heads or refs/tags prefix.
  • Ideal for conditionals and naming.

Related guides

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