'GitHub Actions - Specify Multiple Tags with docker/build-push-action@v2

Is there a way to specify multiple tags when using docker/build-push-action@v2?

I tried specifying multiple tags separated by a space or comma and they both failed.

Error

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


Solution 1:[1]

Check here https://github.com/docker/build-push-action#customizing, add a comma between the tags, like this:

- 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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 XDavidT