🎉

Github Actionsでref情報を取得する方法

2021/06/02に公開
- name: Branch name
        id: branch_name
        run: |
          echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
          echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
          echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
- name: Build base image
        run: |
          echo $SOURCE_NAME
          echo $SOURCE_BRANCH
          echo $SOURCE_TAG
        env:
          SOURCE_NAME: ${{ steps.branch_name.outputs.SOURCE_NAME }}
          SOURCE_BRANCH: ${{ steps.branch_name.outputs.SOURCE_BRANCH }}
          SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }}
- name: version tag add GITHUB_ENV
  run: |
    echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_ENV"
- name: use GITHUB_ENV
  use docker/build-push-action@v2
  with:
    tag: |
      {{ env.DOCKER_IMAGE_NAME }}:{{ env.VERSION }}
    push: true

Discussion