skip to Main Content

I am trying to build a CI/CD using GitHub Actions. So far I am able to check out the code, start the database service, run the test case, built the docker, tag a docker image and then push it to the Artifacts registry. However, now I want to add another tag (before push I already tagged it version) to that image as shown in the below image. But this should happen via Github Actions itself.

enter image description here

After looking for the solutions I have found a command –

gcloud artifacts docker tags add tag ${{ secrets.REGION }}-docker.pkg.dev/${{ secrets.GOOGLE_CLOUD_PROJECT }}/${{ secrets.ARTIFACTS_REPO }}/yacht-away:$GIT_TAG ${{ secrets.REGION }}-docker.pkg.dev/${{ secrets.GOOGLE_CLOUD_PROJECT }}/${{ secrets.ARTIFACTS_REPO }}/yacht-away:latest

I simply replaced the image arguments. In the above command. But this is throwing me an error –

ERROR: (gcloud.artifacts.docker.tags.add) unrecognized arguments: ***-docker.pkg.dev/***/***/***:latest 

To search the help text of gcloud commands, run:
  gcloud help -- SEARCH_TERMS

Where am I going wrong? How can I add multiple tags to an image in Artifacts via GitHub actions.

2

Answers


  1. It is advisable for you to use Docker’s official Build Push action to build and push Docker images to whatever container registry you are using.

    If you have a look over the customization options in the above action, you can just add a comma between the tags for multiple tagging, like this:

    - name: Build and push
      uses: docker/build-push-action@v2
      with:
        context: .
        push: true
        tags: ${{ secrets.DOCKERHUB_USERNAME }}/myapp:${{ steps.vars.outputs.tag }} , ${{ secrets.DOCKERHUB_USERNAME }}/myapp:latest
    
    Login or Signup to reply.
  2. The commad is

    gcloud artifacts docker tags add DOCKER_IMAGE DOCKER_TAG
    

    Not

    gcloud artifacts docker tags add tag DOCKER_IMAGE DOCKER_TAG
    

    source: https://cloud.google.com/sdk/gcloud/reference/artifacts/docker/tags/add

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search