diff --git a/scripts/publish-ift-aux-images.sh b/scripts/publish-ift-aux-images.sh index aa2767b..ec52bb6 100644 --- a/scripts/publish-ift-aux-images.sh +++ b/scripts/publish-ift-aux-images.sh @@ -7,6 +7,21 @@ REGISTRY="${1:?registry}" TAG="${2:?sha-tag}" FILES="${3:-}" +rebuild_image() { + local name="$1" + local context="$2" + local dockerfile="$3" + local reason="$4" + + echo "== ${name}: rebuild (${reason})" + bash scripts/retry-docker-build.sh 3 30 -- \ + docker buildx build -f "${dockerfile}" --push \ + -t "${REGISTRY}/${name}:${TAG}" \ + -t "${REGISTRY}/${name}:ift" \ + --provenance=false --sbom=false \ + "${context}" +} + publish_image() { local name="$1" local path_pattern="$2" @@ -19,20 +34,14 @@ publish_image() { fi if echo "${FILES}" | grep -qE "${path_pattern}"; then - echo "== ${name}: rebuild (matched: ${path_pattern})" - bash scripts/retry-docker-build.sh 3 30 -- \ - docker buildx build -f "${dockerfile}" --push \ - -t "${REGISTRY}/${name}:${TAG}" \ - -t "${REGISTRY}/${name}:ift" \ - --provenance=false --sbom=false \ - "${context}" + rebuild_image "${name}" "${context}" "${dockerfile}" "matched: ${path_pattern}" return fi echo "== ${name}: unchanged, promote :ift -> ${TAG}" if ! docker buildx imagetools inspect "${REGISTRY}/${name}:ift" >/dev/null 2>&1; then - echo "ERROR: ${name}:ift not found and no matching changes in this commit" - exit 1 + rebuild_image "${name}" "${context}" "${dockerfile}" "bootstrap: :ift not found" + return fi docker buildx imagetools create \ -t "${REGISTRY}/${name}:${TAG}" \