@@ -40,33 +40,11 @@ runs:
4040 DOCKER_DEST_REGISTRY=${{ inputs.dest-registry }}
4141 DOCKER_DEST_REPO=${{ inputs.dest-repo }}
4242
43- PUSH_FLAG=" "
43+ DRYRUN_FLAG="--dry-run "
4444 if [ "${{ inputs.dry-run }}" = "false" ]; then
45- PUSH_FLAG="--push "
45+ DRYRUN_FLAG=" "
4646 fi
4747
48- function get_platforms() {
49- local images=${1}
50- platforms=""
51- for image in $images; do
52- _jq() {
53- echo "${image}" | base64 --decode | jq -r "${1}"
54- }
55- os=$(_jq '.os')
56- arch=$(_jq '.architecture')
57- variant=$(_jq '.variant')
58- platform="$os/$arch"
59- if [ -n "$variant" ] && [ "$variant" != "null" ]; then
60- platform="$platform/$variant"
61- fi
62- if [ -n "$platforms" ]; then
63- platforms="$platforms,"
64- fi
65- platforms="$platforms$platform"
66- done
67- echo "$platforms"
68- }
69-
7048 TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${DOCKERHUB_USERNAME}'", "password": "'${DOCKERHUB_PASSWORD}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
7149 if [ -z "${TOKEN}" -o "${TOKEN}" == "null" ]; then
7250 echo >&2 "error: cannot retrieve token"
@@ -79,15 +57,13 @@ runs:
7957 echo "${TAG}" | base64 --decode | jq -r ${1}
8058 }
8159 TAG_NAME=$(_jq '.name')
82- TAG_IMAGES=$(echo "$(_jq '.images')" | jq -r '.[] | @base64')
83- TAG_PLATFORMS=$(get_platforms "${TAG_IMAGES}")
84- echo "::group::Copying ${DOCKERHUB_REPO}:${TAG_NAME} to ${DOCKER_DEST_REGISTRY}/${DOCKER_DEST_REPO}"
85- echo "FROM --platform=\${TARGETPLATFORM:-linux/amd64} ${DOCKERHUB_REPO}:${TAG_NAME}" > Dockerfile.tmp
86- docker buildx build \
87- ${PUSH_FLAG} \
88- --platform "${TAG_PLATFORMS}" \
89- --tag "${DOCKER_DEST_REGISTRY}/${DOCKER_DEST_REPO}:${TAG_NAME}" \
90- --file ./Dockerfile.tmp .
60+ echo "::group::Copying ${DOCKERHUB_REPO}:${TAG_NAME} to ${DOCKER_DEST_REGISTRY}/${DOCKER_DEST_REPO}:${TAG_NAME}"
61+ set -x
62+ docker buildx imagetools create ${DRYRUN_FLAG} --tag "${DOCKER_DEST_REGISTRY}/${DOCKER_DEST_REPO}:${TAG_NAME}" "${DOCKERHUB_REPO}:${TAG_NAME}"
63+ set +x
64+ if [ "${{ inputs.dry-run }}" = "false" ]; then
65+ docker buildx imagetools inspect "${DOCKER_DEST_REGISTRY}/${DOCKER_DEST_REPO}:${TAG_NAME}"
66+ fi
9167 echo "::endgroup"
9268 done
9369 shell : bash
0 commit comments