From 75a0fb9717741e2a0fa9bb41986c251b342ba88f Mon Sep 17 00:00:00 2001 From: George Adams Date: Wed, 14 Aug 2024 15:58:14 +0100 Subject: [PATCH] Update mirror.yml --- .github/workflows/mirror.yml | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml index 8924d89c4..f27b1a3cd 100644 --- a/.github/workflows/mirror.yml +++ b/.github/workflows/mirror.yml @@ -31,8 +31,8 @@ jobs: # Get the supported architectures for this tag ARCHITECTURES=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/${SOURCE_IMAGE}/tags/${tag}/" | jq -r '.images[].architecture' | sort -u) - # List to collect successfully pulled architecture images - ARCH_IMAGES=() + # Create a new manifest for this tag + MANIFEST_IMAGES="" for arch in $ARCHITECTURES; do echo "Processing architecture: $arch for tag: $tag" @@ -48,26 +48,20 @@ jobs: continue fi - TEMP_TAG="${SOURCE_IMAGE}:${tag}-${arch}" - - # Try pulling the image for the specific architecture + # Pull the image for the specific architecture if docker pull --platform=$platform ${SOURCE_IMAGE}:$tag; then - docker tag ${SOURCE_IMAGE}:$tag $TEMP_TAG - ARCH_IMAGES+=("$TEMP_TAG") + docker tag ${SOURCE_IMAGE}:$tag ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag + docker push ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag + MANIFEST_IMAGES="${MANIFEST_IMAGES} ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag" else echo "Skipping $platform for $tag - no matching manifest." fi done # If at least one architecture was successful, create and push a multi-platform manifest - if [ ${#ARCH_IMAGES[@]} -gt 0 ]; then - docker manifest create ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag ${ARCH_IMAGES[@]} + if [ -n "$MANIFEST_IMAGES" ]; then + docker manifest create ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag ${MANIFEST_IMAGES} docker manifest push ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag - - # Delete the temporary tags - for temp_tag in "${ARCH_IMAGES[@]}"; do - docker rmi $temp_tag - done else echo "No architectures were successfully pulled for tag: $tag" fi