Skip to content
git-branch

GitHub Action

Git Branch Name

v1 Latest version

Git Branch Name

git-branch

Git Branch Name

Gets the current git branch name of the running action for both pull_request and push triggers

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Git Branch Name

uses: EthanSK/git-branch-name-action@v1

Learn more about this action in EthanSK/git-branch-name-action

Choose a version

git-branch-name-action

Gets the current git branch name of the running action for both pull_request and push triggers.

UPDATE: Doesn't work if your branch name has '/' in the name...sorry.

Usage

on: [push, pull_request]

jobs:
  main_job:
    runs-on: ubuntu-latest
    steps:
      - name: Git branch name
        id: git-branch-name
        uses: EthanSK/git-branch-name-action@v1
      - name: Echo the branch name
        run: echo "Branch name ${GIT_BRANCH_NAME}"

If you want to check the branch name in an if statement, you can do something like:

if: ${{ env.GIT_BRANCH_NAME == 'master' }}