#!/bin/bash set -e cd "$(dirname "$0")" IMAGE="thetadev256/keycloak" OLD_DIGEST="" if [ -f old_digest ]; then OLD_DIGEST=$(cat old_digest) echo "old digest: $OLD_DIGEST" fi CUR_DIGEST=$(curl -Isf https://quay.io/v2/keycloak/keycloak/manifests/latest | awk -v FS=": " '/^docker-content-digest/{print $2}') echo "current digest: $CUR_DIGEST" if [ "$OLD_DIGEST" != "$CUR_DIGEST" ]; then VERSION=$(curl -sf https://quay.io/v2/keycloak/keycloak/manifests/latest | jq -r '.history[0].v1Compatibility' | jq -r '.config.Labels.version') echo "version: $VERSION" if [[ "$VERSION" =~ ^([0-9]+)\.([0-9]+)\. ]]; then VERSION_MAJOR="${BASH_REMATCH[1]}" VERSION_MINOR="${BASH_REMATCH[2]}" else echo "could not parse version" exit 1 fi docker buildx build --platform linux/amd64,linux/arm64 --push -t "$IMAGE:latest" -t "$IMAGE:$VERSION" -t "$IMAGE:$VERSION_MAJOR" -t "$IMAGE:$VERSION_MAJOR.$VERSION_MINOR" . echo "$CUR_DIGEST" > old_digest docker buildx prune -f curl "https://gotify.thetadev.de/message?token=$GOTIFY_TOKEN" -F "title=Keycloak image built" -F "message=Version: $VERSION - Digest: $CUR_DIGEST" fi