Skip to content

Commit

Permalink
Fix mirroring new images under old tags due to half-published upstrea…
Browse files Browse the repository at this point in the history
…m images on Docker Hub
  • Loading branch information
tyranron committed Dec 2, 2024
1 parent 03531fe commit 4708504
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
NAME: rust
REGISTRY_AUTH_FILE: ./auth.json
SKOPEO_LATEST: true
VERSION: 1.83.0

jobs:
copy:
Expand Down Expand Up @@ -112,7 +113,7 @@ jobs:
echo 'result<<EOF'$'\n'"$result"$'\n'EOF >> $GITHUB_OUTPUT
env:
IMAGE: ${{ matrix.registry }}/${{ github.repository_owner }}/${{ env.NAME }}
IMAGE_OS: ${{ matrix.os }}
SOURCE_TAG: ${{ env.VERSION }}-${{ matrix.os }}
if: ${{ steps.skip.outputs.no == 'true' }}

- name: Login to ${{ matrix.registry }} container registry
Expand All @@ -134,7 +135,7 @@ jobs:
run: bash stable/copy.sh
env:
IMAGE: ${{ matrix.registry }}/${{ github.repository_owner }}/${{ env.NAME }}
IMAGE_OS: ${{ matrix.os }}
SOURCE_TAG: ${{ env.VERSION }}-${{ matrix.os }}
IMAGE_TAGS: ${{ matrix.tags }}
if: ${{ steps.skip.outputs.no == 'true'
&& contains(steps.upstream.outputs.result, 'CHANGED') }}
Expand Down
10 changes: 4 additions & 6 deletions stable/check-changed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@ if [ -z "$IMAGE" ]; then
echo "error: No IMAGE env var provided"
exit 1
fi
if [ -z "$IMAGE_OS" ]; then
echo "error: No IMAGE_OS env var provided"
if [ -z "$SOURCE_TAG" ]; then
echo "error: No SOURCE_TAG env var provided"
exit 1
fi


set -e


upstream=$(skopeo inspect \
--raw docker://docker.io/rust:$IMAGE_OS \
upstream=$(skopeo inspect --raw docker://docker.io/rust:$SOURCE_TAG \
| jq -c '.')
echo "--> Upstream image manifests: $upstream"

latest=$((skopeo inspect \
--raw docker://$IMAGE:$IMAGE_OS \
latest=$((skopeo inspect --raw docker://$IMAGE:$SOURCE_TAG \
|| echo '"none"') \
| jq -c '.')
echo "--> Latest image manifests: $latest"
Expand Down
10 changes: 5 additions & 5 deletions stable/copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ if [ -z "$IMAGE" ]; then
echo "error: No IMAGE env var provided"
exit 1
fi
if [ -z "$IMAGE_OS" ]; then
echo "error: No IMAGE_OS env var provided"
if [ -z "$SOURCE_TAG" ]; then
echo "error: No SOURCE_TAG env var provided"
exit 1
fi
if [ -z "$IMAGE_TAGS" ]; then
Expand All @@ -23,9 +23,9 @@ fi
set -e

runCmd \
podman pull docker.io/rust:$IMAGE_OS
podman pull docker.io/rust:$SOURCE_TAG

fullVer=$(podman run --rm docker.io/rust:$IMAGE_OS rustc -V \
fullVer=$(podman run --rm docker.io/rust:$SOURCE_TAG rustc -V \
| cut -d ' ' -f2 \
| tr -d "\n )")
majorVer=$(printf "$fullVer" | cut -d '.' -f1)
Expand All @@ -38,6 +38,6 @@ tags=$(printf "$IMAGE_TAGS" | sed "s/<full-ver>/$fullVer/g" \

for tag in $tags; do
runCmd \
skopeo copy --all "docker://docker.io/rust:$IMAGE_OS" \
skopeo copy --all "docker://docker.io/rust:$SOURCE_TAG" \
"docker://$IMAGE:$tag"
done

0 comments on commit 4708504

Please sign in to comment.