Skip to content

Commit 1258bc8

Browse files
authored
Use Skopeo to synchronize other images (#146)
1 parent 056e866 commit 1258bc8

File tree

2 files changed

+6
-39
lines changed

2 files changed

+6
-39
lines changed

.github/workflows/releases-images.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,10 @@ jobs:
2828
run: |
2929
OLD_REGISTRY=k8s.gcr.io REGISTRY="ghcr.io/$(echo ${{ github.repository }} | tr "A-Z" "a-z")" make push-image
3030
- name: Sync others image
31+
env:
32+
GH_ID: ${{ github.actor }}
33+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3134
run: |
35+
sudo mkdir -p /run/containers && sudo chmod 777 /run/containers
36+
skopeo login -u ${GH_ID} -p ${GH_TOKEN} ghcr.io
3237
REGISTRY="ghcr.io/$(echo ${{ github.repository }} | tr "A-Z" "a-z")" make image-other

hack/image_manifest_retags.sh

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,13 @@ set -o errexit
44
set -o nounset
55
set -o pipefail
66

7-
DOCKER_CLI_EXPERIMENTAL=enabled
8-
97
REGISTRY=${REGISTRY:-}
108
IMAGES="$@"
119

1210
for image in ${IMAGES[*]}; do
13-
1411
tag=${image#*:}
15-
old_registry=${image%/*}
1612
name=${image%:*}
1713
name=${name##*/}
1814

19-
echo "+++ Creating manifest image ${REGISTRY}/${name}:${tag}"
20-
21-
# raw=$(docker manifest inspect "${image}")
22-
# Bypass permission authorized by docker manifest inspect
23-
raw=$(curl -H "User-Agent:Go-http-client/1.1" -H "Accept:application/vnd.docker.distribution.manifest.list.v2+json" "https://${old_registry}/v2/${name}/manifests/${tag}")
24-
25-
echo "+++ Pulling source images by SHA"
26-
echo "${raw}" |
27-
jq -j ".manifests[] | \"${old_registry}/${name}@\", .digest, \"\n\" " |
28-
while read X; do docker pull $X; done
29-
30-
echo "+++ Tagging images with ARCH and OS"
31-
echo "${raw}" |
32-
jq -j ".manifests[] | \"docker tag ${old_registry}/${name}@\", .digest, \" ${REGISTRY}/${name}:${tag}__\", .platform.architecture, \"_\", .platform.os, \"\n\"" |
33-
while read X; do $X; done
34-
35-
echo "+++ Pushing images"
36-
echo "${raw}" |
37-
jq -j ".manifests[] | \"docker push ${REGISTRY}/${name}:${tag}__\", .platform.architecture, \"_\", .platform.os, \"\n\"" |
38-
while read X; do $X; done
39-
40-
echo "+++ Creating manifest"
41-
docker manifest create --amend "${REGISTRY}/${name}:${tag}" \
42-
$(
43-
echo "${raw}" |
44-
jq -j ".manifests[] | \"${REGISTRY}/${name}:${tag}__\", .platform.architecture, \"_\", .platform.os, \" \""
45-
)
46-
47-
echo "+++ Annotating manifest with ARCH and OS"
48-
echo "${raw}" |
49-
jq -j ".manifests[] | \"docker manifest annotate ${REGISTRY}/${name}:${tag} ${REGISTRY}/${name}:${tag}__\", .platform.architecture, \"_\", .platform.os, \" --arch \", .platform.architecture, \" --os \", .platform.os, \"\n\"" |
50-
while read X; do $X; done
51-
52-
echo "+++ Pushing manifest ${REGISTRY}/${name}:${tag}"
53-
docker manifest push "${REGISTRY}/${name}:${tag}" --purge
15+
skopeo copy --all "docker://${image}" "docker://${REGISTRY}/${name}:${tag}"
5416
done

0 commit comments

Comments
 (0)