Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 806
kernelpanic Avatar asked Dec 01 '25 06:12

kernelpanic


2 Answers

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
like image 168
KafKafOwn Avatar answered Dec 04 '25 07:12

KafKafOwn


You can also use a "newline-delimited string". I think this is better when you have longer strings:

- 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
like image 22
Akaisteph7 Avatar answered Dec 04 '25 09:12

Akaisteph7