Fix target sync image

This commit is contained in:
Shiming Zhang 2025-02-10 10:26:00 +08:00
parent fc8305c7d2
commit 2815c36f92
2 changed files with 23 additions and 7 deletions

View File

@ -46,14 +46,9 @@ jobs:
exit 1
fi
echo "image=${ORIGIN_IMAGE}" >> $GITHUB_OUTPUT
if [[ "${ORIGIN_IMAGE}" =~ ^docker.io/ ]]; then
ORIGIN_IMAGE="registry-1.${ORIGIN_IMAGE}"
fi
if [[ "${ORIGIN_IMAGE}" =~ ^registry-1\.docker\.io/[^/]+$ ]]; then
ORIGIN_IMAGE="registry-1.docker.io/library/${ORIGIN_IMAGE#registry-1.docker.io/}"
fi
echo "sync_image=${ORIGIN_IMAGE}" >> $GITHUB_OUTPUT
SYNC_IMAGE="$(./hack/real-image.sh "${ORIGIN_IMAGE}")"
echo "sync_image=${SYNC_IMAGE}" >> $GITHUB_OUTPUT
- name: Set up crproxy
run: |

21
hack/real-image.sh Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
function guess_image() {
local image="${1}"
if [[ -z "${image}" ]]; then
return
fi
if [[ "${image}" =~ ^"docker.io/"* ]]; then
image="registry-1.${image}"
fi
if [[ "${image}" =~ ^"registry-1.docker.io/"[^/]+$ ]]; then
image="registry-1.docker.io/library/${image#*/}"
fi
echo "${image}"
}
guess_image "${1}"