Getting current branch and commit hash in GitHub action

前端 未结 5 2328
生来不讨喜
生来不讨喜 2021-02-19 05:26

I want to build a docker image using a GitHub action, migrating from TeamCity.

In the build script, I want to tag the image with a combination of branch and commit, e.g.

5条回答
  •  执念已碎
    2021-02-19 06:05

    Another approach is to use github context.

    - name: Create docker image
      run: ./docker-build.sh ${{ github.head_ref }}.${{ github.sha }}
    

    The benefit of this approach is that you don't have to add a step to set the values. Note that it uses the full version of the sha (not the short version).

提交回复
热议问题