Skip to content

Commit

Permalink
Update mirror.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
gdams authored Aug 14, 2024
1 parent 6ef89e7 commit 75a0fb9
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 75a0fb9

Please sign in to comment.