I'd like to set a dash plus the repo tag to a Docker image build if the build is a build of a tag, and neither if it is not, I'll explain...
This would be trivial if I just wanted to set the tag if it existed because this would work:
build-nginx:
stage: build-nginx
script:
- command docker build -t $CI_REGISTRY_IMAGE:nginx$CI_COMMIT_TAG .
- command docker push $CI_REGISTRY_IMAGE:nginx$CI_COMMIT_TAG
This could create registry.example.com/image:nginx if there was no tag and registry.example.com/image:nginx1.0 if there was, but how would I get the image to be named registry.example.com/image:nginx-1.0 (with a dash), I've have to check if the tag variable was set otherwise I'd end up with and image called registry.example.com/image:nginx- if the tag variable was not set.