Edit: Question makes no sense, the branch which triggered the workflow always gets checked out per default.
Is there a way to get the name of the branch which started the workflow in Github Actions? For example, if I push to test/1
, I'd like to use this name in my workflow.
Preferably before checking out the repo since I want to check out the branch which triggered the workflow. And I can't just specify the branch myself since I have multiple branches named test/*
and I want my workflow to handle things dynamically in one workflow without creating a seperate workflow for each branch name.
Example:
name: Workflow
on:
push:
branches: [ test/* ]
jobs:
build:
runs-on: [ self-hosted ]
steps:
- name: Checkout the code
uses: actions/checkout@v2
with:
ref: $branch_name <--- this is where I want to use the branch name for the branch which triggered the workflow on push
fetch-depth: 0