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
What Is GITHUB_REF?GITHUB_REF is the fully-formed ref (branch or tag) that triggered a GitHub Actions run, like refs/heads/main.…
What Is GITHUB_REF_TYPE?GITHUB_REF_TYPE tells you whether a GitHub Actions run was triggered by a branch or a tag. Learn how to branc…
What Is a Git Branch?What is a Git branch? Learn how branches are lightweight movable pointers, how they enable parallel work, and…