Skip to content

Set Git Branch

Actions
Sets the git branch name as a consistent env var output. If the event is triggered by a tag, no value will be set.
1.0.0
Latest
Star (2)

Set Git Branch

This is a dead-simple composite action that uses the github context to provide an environment variable ($GIT_BRANCH) and an output (branch-name) with the branch name that workflow creators are most likely to care about.

Pull Request Events

For Pull Request events (pull_request & pull_request_target) the github context provides the github.head_ref context variable that contains the name of the source branch for the PR.

Other branch-type Events

For other events triggered by branches, the github context provides the github.ref_name variable with the name of the branch or tag that triggered the event, and this is what is used to set the env var & output

Tag Events

Whenever github.ref_type is set to tag, the current event was triggered by a tag, and the github context does not provide any branch-relevant information, so this action provides an empty output and environment variable.

Set Git Branch is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Sets the git branch name as a consistent env var output. If the event is triggered by a tag, no value will be set.
1.0.0
Latest

Set Git Branch is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.