GH-200 practice question 5 of 15

Which default environment variable specifies the branch or tag that triggered a workflow?

Full set: 100 questions
Answer options
A: GITHUB_TAG
B: GITHUB_REF Correct answer
C: ENV_BRANCH
D: GITHUB_BRANCH
Correct Answer:
B. GITHUB_REF
Explanation

GitHub Actions automatically populates a set of default environment variables for every workflow run. The GITHUBREF variable contains the fully-qualified reference (ref) of the branch or tag that triggered the workflow. For a branch, its format is refs/heads/, and for a tag, it is refs/tags/. This makes it the definitive variable for identifying the exact source ref.

Why Incorrect

A. GITHUBTAG is a deprecated variable; the modern equivalent for just the name is GITHUBREFNAME. GITHUBREF is the correct, comprehensive variable.
C. ENVBRANCH is not a standard default environment variable provided by GitHub Actions.
D. GITHUBBRANCH is not a standard default environment variable. The GITHUBREFNAME variable provides just the branch or tag name.

References

- GitHub Docs. (2024). "Using environment variables." In Guides. Retrieved from https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables. The table of default variables lists GITHUBREF and describes it as "The branch or tag ref that triggered the workflow run."

Scroll to Top