From d246b9d172af9cc417aba8a92434cd4a606ee039 Mon Sep 17 00:00:00 2001 From: Carlos Camacho Date: Wed, 24 Jul 2024 16:08:25 +0200 Subject: [PATCH] ci: fix container images in quay This commit makes sure the images labels also match the hashes so we make sure we have the latest image for each hash. --- ci/container_sync.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/ci/container_sync.sh b/ci/container_sync.sh index 37092fc72..c20b71f0c 100755 --- a/ci/container_sync.sh +++ b/ci/container_sync.sh @@ -82,12 +82,22 @@ for image in "${container_images[@]}"; do container=${strarr[1]} tag=${strarr[2]} exists=$(curl -H "Authorization: Bearer XYZ" -X GET "https://quay.io/api/v1/repository/kubeinit/$container/tag/" | jq .tags[].name | grep \"$tag\" | uniq) - if [ -z "$exists" ] || [ "$exists" == "\"latest\"" ]; then - echo "The tag $tag in kubeinit/$container is not found or is latest, lets copy the container image." - copy="skopeo copy docker://docker.io/$namespace/$container:$tag docker://quay.io/kubeinit/$container:$tag" - retry 5 $copy + + if [ -n "$exists" ]; then + quay_hash=$(skopeo inspect --raw docker://quay.io/kubeinit/$container:$tag | jq -r '.digest') + docker_hash=$(skopeo inspect --raw docker://docker.io/$namespace/$container:$tag | jq -r '.digest') + + if [ "$quay_hash" == "$docker_hash" ]; then + echo "The image hashes for tag $tag in kubeinit/$container and docker.io/$namespace/$container match. No update needed." + continue + else + echo "The image hashes for tag $tag in kubeinit/$container and docker.io/$namespace/$container do not match. Updating the image." + fi else - echo "The tag $tag in kubeinit/$container is found and is not latest, no need to copy anything." + echo "The tag $tag in kubeinit/$container is not found. Copying the container image." fi + copy="skopeo copy docker://docker.io/$namespace/$container:$tag docker://quay.io/kubeinit/$container:$tag" + retry 5 $copy + done