How to get current branch within github actions

前端 未结 13 2102
-上瘾入骨i
-上瘾入骨i 2020-11-29 20:11

I\'m building docker images with Github Actions and want to tags images with branch name, I found only GITHUB_REF variable, but it results in refs/heads/f

13条回答
  •  难免孤独
    2020-11-29 21:02

    Be aware that if you are executing your GitHub action on pull request trigger, then GITHUB_REF variable will contain something like refs/pull/421/merge so if you will try to git push to that name it will most likely fail.

    What you can use though are references on the GitHub context in your YAML. Something like: ${{ github.head_ref }}

    https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#github-context

提交回复
热议问题