diff --git a/ci-automation/ci_automation_common.sh b/ci-automation/ci_automation_common.sh index 1ded3d1e36f..d7e22c12b04 100644 --- a/ci-automation/ci_automation_common.sh +++ b/ci-automation/ci_automation_common.sh @@ -235,6 +235,17 @@ function docker_image_from_buildcache() { if [[ -n "${local_image}" ]] ; then local image_id="" image_id=$($docker image inspect "${local_image}" | jq -r '.[].Id' | sed 's/^sha256://') + + local local_id_file="${name}-${version}.local-id" + if [[ -f "${local_id_file}" ]] ; then + local cached_id="" + cached_id=$(cat "${local_id_file}") + if [[ "${image_id}" = "${cached_id}" ]] ; then + echo "Local image is up-to-date (cached ID match)" >&2 + return + fi + fi + local remote_id="" remote_id=$(curl --fail --silent --show-error --location --retry-delay 1 \ --retry 60 --retry-connrefused --retry-max-time 60 --connect-timeout 20 \ @@ -270,6 +281,17 @@ function docker_image_from_buildcache() { zstd -d -c ${tgz} | $docker load rm "${tgz}" + + local loaded_image="" + if image_exists_locally "${name}" "${version}" ; then + loaded_image="${name}:${version}" + elif image_exists_locally "${CONTAINER_REGISTRY}/${name}" "${version}" ; then + loaded_image="${CONTAINER_REGISTRY}/${name}:${version}" + fi + if [[ -n "${loaded_image}" ]] ; then + local local_id_file="${name}-${version}.local-id" + $docker image inspect "${loaded_image}" | jq -r '.[].Id' | sed 's/^sha256://' > "${local_id_file}" + fi } # --