I'm using GitHub Actions to build a docker image using the build-push-action. I'd like to add tags to the image before pushing it to the docker registry:
- Each image should be tagged with
latest
- If the commit that triggered the build has a git tag attached, the image should be tagged with this tag as well.
I have something along the lines of:
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: true
tags:
- user/image:latest
It would be easy to always add more tags, but I want to add it only if there's a git tag. Is there a way to do that?