renovate/hooks/post_push

27 lines
608 B
Bash

#!/bin/bash
set -e
echo "repo=${DOCKER_REPO}"
echo "tag=${DOCKER_TAG}"
SEMVER_REGEX="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-slim)?$"
if ! [[ "$DOCKER_TAG" =~ $SEMVER_REGEX ]]; then
echo Not a semver tag - skipping
exit
fi
major=${BASH_REMATCH[1]}
minor=${BASH_REMATCH[2]}
slim=${BASH_REMATCH[4]}
latest=${slim:1}
latest=${latest:-latest}
# Tag and push image for each additional tag
for tag in {"${major}${slim}","${major}.${minor}${slim}","${latest}"}; do
echo "Tagging ${DOCKER_REPO}:${tag}"
docker tag $IMAGE_NAME ${DOCKER_REPO}:${tag}
docker push ${DOCKER_REPO}:${tag}
done