【问题标题】:GitHub Actions - Specify Multiple Tags with docker/build-push-action@v2GitHub Actions - 使用 docker/build-push-action@v2 指定多个标签
【发布时间】:2022-11-11 02:16:36
【问题描述】:

使用docker/build-push-action@v2时有没有办法指定多个标签?

我尝试指定多个用空格或逗号分隔的标签,但它们都失败了。

错误

buildx failed with: error: invalid tag "***/myapp:1.4.0 ***/myapp:latest": invalid reference format

.github/workflows/publish.yml

- name: Build and push
  id: docker_build
  uses: docker/build-push-action@v2
  with:
    context: .
    push: true
    tags: ${{ secrets.DOCKER_HUB_USERNAME }}/myapp:${{ steps.vars.outputs.tag }} ${{ secrets.DOCKER_HUB_USERNAME }}/myapp:latest

【问题讨论】:

    标签: docker github-actions


    【解决方案1】:

    检查这里https://github.com/docker/build-push-action#customizing,在标签之间添加一个逗号,像这样:

    - name: Build and push
      id: docker_build
      uses: docker/build-push-action@v2
      with:
        context: .
        push: true
        tags: ${{ secrets.DOCKER_HUB_USERNAME }}/myapp:${{ steps.vars.outputs.tag }} , ${{ secrets.DOCKER_HUB_USERNAME }}/myapp:latest
    

    【讨论】:

      【解决方案2】:

      您还可以使用“换行符分隔的字符串”。我认为当你有更长的字符串时这会更好:

      - name: Build and push
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          tags: |
            ${{ secrets.DOCKER_HUB_USERNAME }}/myapp:${{ steps.vars.outputs.tag }}
            ${{ secrets.DOCKER_HUB_USERNAME }}/myapp:latest
      

      【讨论】:

        猜你喜欢
        • 2021-01-01
        • 2021-08-24
        • 2021-12-23
        • 2022-08-24
        • 1970-01-01
        • 2021-11-22
        • 1970-01-01
        • 2021-09-02
        • 2020-08-12
        相关资源
        最近更新 更多