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.
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.
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