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 2556158 commit de1e95a
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ 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
SUCCESSFUL_ARCHS=()
for arch in $ARCHITECTURES; do
echo "Processing architecture: $arch for tag: $tag"
Expand All @@ -39,18 +42,29 @@ jobs:
platform="windows/amd64"
fi
# Skip if trying to pull Windows images on Linux
if [[ "$arch" == "windows-amd64" ]] && [[ "$(uname -s)" != "Linux" ]]; then
echo "Skipping Windows-specific tag on a non-Windows runner: $tag"
continue
fi
# 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}-${arch}
docker push ${TARGET_REGISTRY}/${SOURCE_IMAGE}:${tag}-${arch}
docker tag ${SOURCE_IMAGE}:$tag ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag
docker push ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag
SUCCESSFUL_ARCHS+=("$arch")
else
echo "Skipping $platform for $tag - no matching manifest."
fi
done
# Create and push a multi-platform manifest
docker manifest create ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag \
$(for arch in $ARCHITECTURES; do echo "${TARGET_REGISTRY}/${SOURCE_IMAGE}:${tag}-${arch}"; 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)
docker manifest push ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag
docker manifest push ${TARGET_REGISTRY}/${SOURCE_IMAGE}:$tag
else
echo "No architectures were successfully pulled for tag: $tag"
fi
done

0 comments on commit de1e95a

Please sign in to comment.