Bug
Currently, the working branch determination in the Github environment relies on the GITHUB_REF environment variable value.
But this works correctly only if the workflow was triggered by pretty limited number of events: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
Only the ones that update the GITHUB_REF.
For instance, in my case I start semantic-release in the workflow that is triggered by the workflow_run event and I explicitly checkout the repository main branch in it:
name: Build
on:
workflow_run:
workflows:
- Run tests
types:
- completed
-
jobs:
BuildApp:
name: Build application
runs-on: ubuntu-latest
outputs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.workflow_run.head_branch }}
...
And in that case, GITHUB_REF points to the default repository branch (which is develop in my case), but I'm working with the main branch.
As we anyway in the environment that should have a git CLI, why not just get the current branch from the git branch output execution, if that is possible?
Environment:
Bug
Currently, the working branch determination in the Github environment relies on the
GITHUB_REFenvironment variable value.But this works correctly only if the workflow was triggered by pretty limited number of events: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
Only the ones that update the GITHUB_REF.
For instance, in my case I start semantic-release in the workflow that is triggered by the
workflow_runevent and I explicitly checkout the repositorymainbranch in it:And in that case,
GITHUB_REFpoints to the default repository branch (which isdevelopin my case), but I'm working with themainbranch.As we anyway in the environment that should have a
gitCLI, why not just get the current branch from thegit branchoutput execution, if that is possible?Environment: