Skip to content

Commit

Permalink
ci: fix container images in quay
Browse files Browse the repository at this point in the history
This commit makes sure the images
labels also match the hashes so
we make sure we have the latest image
for each hash.
  • Loading branch information
ccamacho committed Jul 24, 2024
1 parent 931121a commit d246b9d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions ci/container_sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d246b9d

Please sign in to comment.