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.
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' }}