add default tag (#1)
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/tag/build Pipeline was successful

Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2023-03-12 11:49:44 +01:00
parent 32dd1a47f7
commit b7b4b734be

View File

@@ -28,18 +28,23 @@ fi
echo "${BASE}" | grep -q "/" || BASE="library/${BASE}" echo "${BASE}" | grep -q "/" || BASE="library/${BASE}"
echo "${TARGET}" | grep -q "/" || TARGET="library/${TARGET}" echo "${TARGET}" | grep -q "/" || TARGET="library/${TARGET}"
# if no tag is give default to latest
echo "${BASE}" | grep -q ":" || BASE="${BASE}:latest"
echo "${TARGET}" | grep -q ":" || TARGET="${TARGET}:latest"
# move tha tag to its own var and remove it from the repo name
# move the tag to its own var and remove it from the repo name
BASE_TAG=$(echo "${BASE}" | sed 's/[^:]*://') BASE_TAG=$(echo "${BASE}" | sed 's/[^:]*://')
TARGET_TAG=$(echo "${TARGET}" | sed 's/[^:]*://') TARGET_TAG=$(echo "${TARGET}" | sed 's/[^:]*://')
BASE_REPO=$(echo "${BASE}" | sed 's/:.*//') BASE_REPO=$(echo "${BASE}" | sed 's/:.*//')
TARGET_REPO=$(echo "${TARGET}" | sed 's/:.*//') TARGET_REPO=$(echo "${TARGET}" | sed 's/:.*//')
# build the url to the repo
BASE_URL="https://hub.docker.com/v2/repositories/${BASE_REPO}/tags/${BASE_TAG}" BASE_URL="https://hub.docker.com/v2/repositories/${BASE_REPO}/tags/${BASE_TAG}"
TARGET_URL="https://hub.docker.com/v2/repositories/${TARGET_REPO}/tags/${TARGET_TAG}" TARGET_URL="https://hub.docker.com/v2/repositories/${TARGET_REPO}/tags/${TARGET_TAG}"
# login if credentias are passed # login if credentias are passed
HEADER="" HEADER=""
if [ -n "${DOCKER_USERNAME}" ] && [ -n "${DOCKER_PASSWORD}" ]; then if [ -n "${DOCKER_USERNAME}" ] && [ -n "${DOCKER_PASSWORD}" ]; then