Skip to content

Github Action that sets the relevant git branch name as a consistent env var & output. If the event is triggered by a tag, no value will be set.

Notifications You must be signed in to change notification settings

jskrzypek/set-git-branch-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

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.

About

Github Action that sets the relevant git branch name as a consistent env var & output. If the event is triggered by a tag, no value will be set.

Resources

Stars

Watchers

Forks

Packages

No packages published