diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cd011d1..dcca81a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -109,3 +109,22 @@ jobs: # output e.g. : master feat-new-feature v1-0-0 product-1-0-0-rc-2 new-awesome-product echo "Short SHA variables" echo " - ${{ env.GITHUB_SHA_SHORT }}" + + which_branch: + runs-on: ubuntu-latest + steps: + # extract branch name + - name: Extract branch name + if: github.event_name != 'pull_request' + shell: bash + run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV + id: extract_branch + + # extract branch name on pull request + - name: Print branch name + if: github.event_name == 'pull_request' + run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF})" >> $GITHUB_ENV + + # print branch name + - name: Get branch name + run: echo 'The branch name is' $BRANCH_NAME