fail2ban-prometheus-exporter/.gitlab-ci/tagLatestImage.sh
Hector 812f506432 feat: tag docker images with extra labels (!85)
Add a new build step to tag docker images with extra labels:
- `:latest`
- `:<major>`
- `:<major>.<minor>`

This job is only triggered on main release tags.

https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/-/merge_requests/85
2023-06-20 07:20:11 +00:00

14 lines
480 B
Bash
Executable file

#!/bin/sh
VERSION=`echo $CI_COMMIT_TAG | cut -c 2-`
MAJOR=`echo $VERSION | cut -d "." -f 1`
MINOR=`echo $VERSION | cut -d "." -f 2`
echo "version: $VERSION (major: $MAJOR; minor: $MINOR)"
docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
docker pull $IMAGE_NAME:$VERSION
docker tag $IMAGE_NAME:$VERSION $IMAGE_NAME:latest
docker tag $IMAGE_NAME:$VERSION $IMAGE_NAME:$MAJOR
docker tag $IMAGE_NAME:$VERSION $IMAGE_NAME:$MAJOR.$MINOR
docker push $IMAGE_NAME