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 de1e95a commit 9dca387
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
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
SUCCESSFUL_ARCHS=()
ARCH_IMAGES=()
for arch in $ARCHITECTURES; do
echo "Processing architecture: $arch for tag: $tag"
Expand All @@ -50,19 +50,17 @@ jobs:
# Try pulling the image for the specific architecture
if docker pull --platform=$platform ${SOURCE_IMAGE}:$tag; then
docker tag ${SOURCE_IMAGE}:$tag ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag
docker push ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag
SUCCESSFUL_ARCHS+=("$arch")
docker tag ${SOURCE_IMAGE}:$tag ${TARGET_REGISTRY}/${SOURCE_IMAGE}:${tag}-${arch}
docker push ${TARGET_REGISTRY}/${SOURCE_IMAGE}:${tag}-${arch}
ARCH_IMAGES+=("${TARGET_REGISTRY}/${SOURCE_IMAGE}:${tag}-${arch}")
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 [ ${#SUCCESSFUL_ARCHS[@]} -gt 0 ]; then
docker manifest create ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag \
$(for arch in ${SUCCESSFUL_ARCHS[@]}; do echo "${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag"; done)
if [ ${#ARCH_IMAGES[@]} -gt 0 ]; then
docker manifest create ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag ${ARCH_IMAGES[@]}
docker manifest push ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag
else
echo "No architectures were successfully pulled for tag: $tag"
Expand Down

0 comments on commit 9dca387

Please sign in to comment.