From 74800fee55b9fbab9b7201d86f7b7d0d61b97606 Mon Sep 17 00:00:00 2001 From: vista Date: Sun, 12 Mar 2023 11:11:48 +0100 Subject: [PATCH 01/53] add default tag --- check.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/check.sh b/check.sh index 363d0a5..2643ba7 100644 --- a/check.sh +++ b/check.sh @@ -36,10 +36,20 @@ TARGET_TAG=$(echo "${TARGET}" | sed 's/[^:]*://') BASE_REPO=$(echo "${BASE}" | sed 's/:.*//') TARGET_REPO=$(echo "${TARGET}" | sed 's/:.*//') +# if no tag is give default to latest +if [ -z "${BASE_TAG}" ]; then + BASE_TAG="latest" +fi + +if [ -z "${TARGET_TAG}" ]; then + TARGET_TAG="latest" +fi + + +# build the url to the repo 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}" - # login if credentias are passed HEADER="" if [ -n "${DOCKER_USERNAME}" ] && [ -n "${DOCKER_PASSWORD}" ]; then From 9dde049945871fc2266a5b034415af222428ead5 Mon Sep 17 00:00:00 2001 From: vista Date: Sun, 12 Mar 2023 11:16:15 +0100 Subject: [PATCH 02/53] Update '.woodpecker/build.yml' --- .woodpecker/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml index 12bfb61..da82400 100644 --- a/.woodpecker/build.yml +++ b/.woodpecker/build.yml @@ -19,6 +19,7 @@ pipeline: password: from_secret: DOCKERHUB_TOKEN repo: vistanarvas/${CI_REPO_NAME} + tag: ${CI_COMMIT_BRANCH} auto_tag: true when: cron: nightly From 07925fd8959d8571796bd70706f23e5d0e8b5703 Mon Sep 17 00:00:00 2001 From: vista Date: Sun, 12 Mar 2023 11:28:49 +0100 Subject: [PATCH 03/53] Update 'check.sh' --- check.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/check.sh b/check.sh index 2643ba7..e47fbad 100644 --- a/check.sh +++ b/check.sh @@ -28,6 +28,10 @@ fi echo "${BASE}" | grep -q "/" || BASE="library/${BASE}" 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 BASE_TAG=$(echo "${BASE}" | sed 's/[^:]*://') @@ -36,15 +40,6 @@ TARGET_TAG=$(echo "${TARGET}" | sed 's/[^:]*://') BASE_REPO=$(echo "${BASE}" | sed 's/:.*//') TARGET_REPO=$(echo "${TARGET}" | sed 's/:.*//') -# if no tag is give default to latest -if [ -z "${BASE_TAG}" ]; then - BASE_TAG="latest" -fi - -if [ -z "${TARGET_TAG}" ]; then - TARGET_TAG="latest" -fi - # build the url to the repo BASE_URL="https://hub.docker.com/v2/repositories/${BASE_REPO}/tags/${BASE_TAG}" From 7c01b16e88ce1850f3bf67aa8fad77de56ade18b Mon Sep 17 00:00:00 2001 From: vista Date: Sun, 12 Mar 2023 11:32:18 +0100 Subject: [PATCH 04/53] Update 'check.sh' [CI SKIP] --- check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check.sh b/check.sh index e47fbad..4bce6ac 100644 --- a/check.sh +++ b/check.sh @@ -33,7 +33,7 @@ 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/[^:]*://') TARGET_TAG=$(echo "${TARGET}" | sed 's/[^:]*://') From 3823ddf8a6896c7a1ff80f1d27dbc10084422ae5 Mon Sep 17 00:00:00 2001 From: vista Date: Sun, 12 Mar 2023 11:48:37 +0100 Subject: [PATCH 05/53] Update '.woodpecker/build.yml' --- .woodpecker/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml index da82400..12bfb61 100644 --- a/.woodpecker/build.yml +++ b/.woodpecker/build.yml @@ -19,7 +19,6 @@ pipeline: password: from_secret: DOCKERHUB_TOKEN repo: vistanarvas/${CI_REPO_NAME} - tag: ${CI_COMMIT_BRANCH} auto_tag: true when: cron: nightly From e1590f94d426c1e69d166cb1ea014a795956d3ec Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 14:15:14 +0100 Subject: [PATCH 06/53] wip [skip ci] --- check.sh | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/check.sh b/check.sh index 4bce6ac..9336dfb 100644 --- a/check.sh +++ b/check.sh @@ -23,6 +23,35 @@ if [ -z "${TARGET}" ]; then exit 1 fi +if [ -z "${REPO_URL}" ]; then + REPO_URL="https://hub.docker.com/v2/repositories" +fi + +if [ -z "${BASE_REPO_URL}" ]; then + BASE_REPO_URL="${REPO_URL}" +fi + +if [ -z "${TARGET_REPO_URL}" ]; then + TARGET_REPO_URL="${REPO_URL}" +fi + +if [ -z "${BASE_REPO_USERNAME}" && -n "${REPO_USERNAME}" ]; then + BASE_REPO_USERNAME="${REPO_USERNAME}" +fi + +if [ -z "${BASE_REPO_PASSWORD}" && -n "${REPO_PASSWORD}" ]; then + BASE_REPO_PASSWORD="${REPO_PASSWORD}" +fi + + +if [ -z "${TARGET_REPO_USERNAME}" && -n "${REPO_USERNAME}" ]; then + TARGET_REPO_USERNAME="${REPO_USERNAME}" +fi + +if [ -z "${TARGET_REPO_PASSWORD}" && -n "${REPO_PASSWORD}" ]; then + BASE_REPO_PASSWORD="${REPO_PASSWORD}" +fi + # add "library/" if its a "official" docker image (it has no username) echo "${BASE}" | grep -q "/" || BASE="library/${BASE}" @@ -42,8 +71,8 @@ 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}" -TARGET_URL="https://hub.docker.com/v2/repositories/${TARGET_REPO}/tags/${TARGET_TAG}" +BASE_URL="${BASE_REPO_URL}/${BASE_REPO}/tags/${BASE_TAG}" +TARGET_URL="${TARGET_REPO_URL}/${TARGET_REPO}/tags/${TARGET_TAG}" # login if credentias are passed HEADER="" From 859ea03824e0cc93197d2af449e8c01198317281 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 15:04:12 +0100 Subject: [PATCH 07/53] Update '.woodpecker/build.yml' --- .woodpecker/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml index 12bfb61..8278458 100644 --- a/.woodpecker/build.yml +++ b/.woodpecker/build.yml @@ -1,3 +1,6 @@ +when: + branch: master + pipeline: check_self: # failure: ignore # this doesnt work From 42dacd7a2aa38ca94bb15a043ebd49c16ba5d176 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 15:10:52 +0100 Subject: [PATCH 08/53] Add '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .woodpecker/build-dev.yml diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml new file mode 100644 index 0000000..0fda8ba --- /dev/null +++ b/.woodpecker/build-dev.yml @@ -0,0 +1,20 @@ +when: + branch: dev + path: + include: [ '.woodpecker/build-dev.yml', 'Dockerfile', 'check.sh' ] + +pipeline: + build_and_publish: + image: woodpeckerci/plugin-docker-buildx + settings: + repo: vistanarvas/${CI_REPO_NAME},vista/${CI_REPO_NAME} + tag: dev + logins: + - registry: https://index.docker.io/v1/ + username: vistanarvas + password: + from_secret: DOCKERHUB_TOKEN + - registry: https://git.narvas.tech/ + username: vista + password: + from_secret: GITEA_TOKEN \ No newline at end of file From a9e328e00c0a8a7b245215223ea86cbf4a2bd1ac Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 15:12:33 +0100 Subject: [PATCH 09/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 0fda8ba..b3d8b7f 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -10,7 +10,7 @@ pipeline: repo: vistanarvas/${CI_REPO_NAME},vista/${CI_REPO_NAME} tag: dev logins: - - registry: https://index.docker.io/v1/ + - registry: https://index.docker.io/v2/ username: vistanarvas password: from_secret: DOCKERHUB_TOKEN From ca677224c2c6d5946ecccc24e44457652f613da0 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 15:15:07 +0100 Subject: [PATCH 10/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index b3d8b7f..6f8dc34 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -13,7 +13,7 @@ pipeline: - registry: https://index.docker.io/v2/ username: vistanarvas password: - from_secret: DOCKERHUB_TOKEN + from_secret: dockerhub_token - registry: https://git.narvas.tech/ username: vista password: From a65d010e7349c47dbfcc86300d9f9fd6b70dfd50 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 15:17:24 +0100 Subject: [PATCH 11/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 6f8dc34..fad7947 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -6,15 +6,14 @@ when: pipeline: build_and_publish: image: woodpeckerci/plugin-docker-buildx + secrets: [ dockerhub_token, gitea_token ] settings: repo: vistanarvas/${CI_REPO_NAME},vista/${CI_REPO_NAME} tag: dev logins: - registry: https://index.docker.io/v2/ username: vistanarvas - password: - from_secret: dockerhub_token + password: ${DOCKERHUB_TOKEN} - registry: https://git.narvas.tech/ username: vista - password: - from_secret: GITEA_TOKEN \ No newline at end of file + password: ${GITEA_TOKEN} \ No newline at end of file From f77e33e8b00317046bc1b8802550a6132688e1ff Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 15:18:17 +0100 Subject: [PATCH 12/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index fad7947..0f93647 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -13,7 +13,9 @@ pipeline: logins: - registry: https://index.docker.io/v2/ username: vistanarvas - password: ${DOCKERHUB_TOKEN} + password: + from_secret: dockerhub_token - registry: https://git.narvas.tech/ username: vista - password: ${GITEA_TOKEN} \ No newline at end of file + password: + from_secret: gitea_token \ No newline at end of file From bdf803c1f64e7dcdb667338278cd753b04de2c8c Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 15:20:38 +0100 Subject: [PATCH 13/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 0f93647..bb17c5d 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -8,7 +8,7 @@ pipeline: image: woodpeckerci/plugin-docker-buildx secrets: [ dockerhub_token, gitea_token ] settings: - repo: vistanarvas/${CI_REPO_NAME},vista/${CI_REPO_NAME} + repo: vistanarvas/${CI_REPO_NAME}, vista/${CI_REPO_NAME} tag: dev logins: - registry: https://index.docker.io/v2/ From 2417ee86877c00f662e8a11b72107955aae1188c Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 15:28:41 +0100 Subject: [PATCH 14/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index bb17c5d..96d3130 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -8,14 +8,14 @@ pipeline: image: woodpeckerci/plugin-docker-buildx secrets: [ dockerhub_token, gitea_token ] settings: - repo: vistanarvas/${CI_REPO_NAME}, vista/${CI_REPO_NAME} + repo: vistanarvas/${CI_REPO_NAME} tag: dev logins: - registry: https://index.docker.io/v2/ username: vistanarvas password: from_secret: dockerhub_token - - registry: https://git.narvas.tech/ - username: vista - password: - from_secret: gitea_token \ No newline at end of file + # - registry: https://git.narvas.tech/ + # username: vista + # password: + # from_secret: gitea_token \ No newline at end of file From 0daa6da70fe593c83dc37da0f60ccad4a02fa5e6 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 15:32:56 +0100 Subject: [PATCH 15/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 96d3130..22049df 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -8,13 +8,20 @@ pipeline: image: woodpeckerci/plugin-docker-buildx secrets: [ dockerhub_token, gitea_token ] settings: + username: vistanarvas + password: + from_secret: DOCKERHUB_TOKEN repo: vistanarvas/${CI_REPO_NAME} tag: dev - logins: - - registry: https://index.docker.io/v2/ - username: vistanarvas - password: - from_secret: dockerhub_token + + # settings: + # repo: vistanarvas/${CI_REPO_NAME} + # tag: dev + # logins: + # - registry: https://index.docker.io/v2/ + # username: vistanarvas + # password: + # from_secret: dockerhub_token # - registry: https://git.narvas.tech/ # username: vista # password: From 17bad16719dc128d0921f5395e098f9ea3890b7d Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 15:40:46 +0100 Subject: [PATCH 16/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 22049df..b97c62a 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -5,7 +5,7 @@ when: pipeline: build_and_publish: - image: woodpeckerci/plugin-docker-buildx + image: woodpeckerci/plugin-docker-buildx:latest secrets: [ dockerhub_token, gitea_token ] settings: username: vistanarvas @@ -13,15 +13,11 @@ pipeline: from_secret: DOCKERHUB_TOKEN repo: vistanarvas/${CI_REPO_NAME} tag: dev - - # settings: - # repo: vistanarvas/${CI_REPO_NAME} - # tag: dev - # logins: - # - registry: https://index.docker.io/v2/ - # username: vistanarvas - # password: - # from_secret: dockerhub_token + logins: + - registry: https://index.docker.io/v2/ + username: vistanarvas + password: + from_secret: dockerhub_token # - registry: https://git.narvas.tech/ # username: vista # password: From 5cd265f7b930fa7b4710d12618bbf744cbb909cb Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:04:26 +0100 Subject: [PATCH 17/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index b97c62a..71b8bd8 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -18,7 +18,7 @@ pipeline: username: vistanarvas password: from_secret: dockerhub_token - # - registry: https://git.narvas.tech/ - # username: vista - # password: - # from_secret: gitea_token \ No newline at end of file + - registry: https://git.narvas.tech/ + username: vista + password: + from_secret: gitea_token \ No newline at end of file From 468560068cdda813b2182e8783a327b5de873c20 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:09:03 +0100 Subject: [PATCH 18/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 71b8bd8..0092f76 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -11,7 +11,7 @@ pipeline: username: vistanarvas password: from_secret: DOCKERHUB_TOKEN - repo: vistanarvas/${CI_REPO_NAME} + repo: vistanarvas/${CI_REPO_NAME}, vista/${CI_REPO_NAME} tag: dev logins: - registry: https://index.docker.io/v2/ From 711c8c321546b25d61fe0f540d993b413dddb859 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:11:11 +0100 Subject: [PATCH 19/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 0092f76..6b9f8e6 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -11,14 +11,14 @@ pipeline: username: vistanarvas password: from_secret: DOCKERHUB_TOKEN - repo: vistanarvas/${CI_REPO_NAME}, vista/${CI_REPO_NAME} + repo: vistanarvas/${CI_REPO_NAME} tag: dev logins: - registry: https://index.docker.io/v2/ username: vistanarvas password: from_secret: dockerhub_token - - registry: https://git.narvas.tech/ + - registry: https://git.narvas.tech/vista/${CI_REPO_NAME} username: vista password: from_secret: gitea_token \ No newline at end of file From b1acc80b72b8896a846b1b286944589da4a97a9b Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:12:14 +0100 Subject: [PATCH 20/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 6b9f8e6..52bb6ae 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -8,13 +8,9 @@ pipeline: image: woodpeckerci/plugin-docker-buildx:latest secrets: [ dockerhub_token, gitea_token ] settings: - username: vistanarvas - password: - from_secret: DOCKERHUB_TOKEN - repo: vistanarvas/${CI_REPO_NAME} tag: dev logins: - - registry: https://index.docker.io/v2/ + - registry: https://index.docker.io/v2/vistanarvas/${CI_REPO_NAME} username: vistanarvas password: from_secret: dockerhub_token From 25da569881bc6a16e9fe192d7d659d1eca32e95f Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:14:01 +0100 Subject: [PATCH 21/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 52bb6ae..5dfc699 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -8,6 +8,7 @@ pipeline: image: woodpeckerci/plugin-docker-buildx:latest secrets: [ dockerhub_token, gitea_token ] settings: + repo: vistanarvas/${CI_REPO_NAME} tag: dev logins: - registry: https://index.docker.io/v2/vistanarvas/${CI_REPO_NAME} From 8c565255d866d6bdb6449c4120e2d9b78f9f5069 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:15:02 +0100 Subject: [PATCH 22/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 5dfc699..563b104 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -11,7 +11,7 @@ pipeline: repo: vistanarvas/${CI_REPO_NAME} tag: dev logins: - - registry: https://index.docker.io/v2/vistanarvas/${CI_REPO_NAME} + - registry: https://index.docker.io/v2/ username: vistanarvas password: from_secret: dockerhub_token From d722c1f28f431d0cb39446575c6a787fe4ac098d Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:18:57 +0100 Subject: [PATCH 23/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 563b104..562b9ac 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -8,14 +8,12 @@ pipeline: image: woodpeckerci/plugin-docker-buildx:latest secrets: [ dockerhub_token, gitea_token ] settings: - repo: vistanarvas/${CI_REPO_NAME} - tag: dev logins: - - registry: https://index.docker.io/v2/ + - registry: https://index.docker.io/v2/vistanarvas/${CI_REPO_NAME}:dev username: vistanarvas password: from_secret: dockerhub_token - - registry: https://git.narvas.tech/vista/${CI_REPO_NAME} + - registry: https://git.narvas.tech/vista/${CI_REPO_NAME}:dev username: vista password: from_secret: gitea_token \ No newline at end of file From 88132ab9a5449a586aeeae035f3a897a71bc7fb6 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:20:51 +0100 Subject: [PATCH 24/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 562b9ac..030c02c 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -7,13 +7,14 @@ pipeline: build_and_publish: image: woodpeckerci/plugin-docker-buildx:latest secrets: [ dockerhub_token, gitea_token ] + repo: vistanarvas/${CI_REPO_NAME},https://git.narvas.tech/vista/${CI_REPO_NAME} settings: logins: - - registry: https://index.docker.io/v2/vistanarvas/${CI_REPO_NAME}:dev + - registry: https://index.docker.io/v2/ username: vistanarvas password: from_secret: dockerhub_token - - registry: https://git.narvas.tech/vista/${CI_REPO_NAME}:dev + - registry: https://git.narvas.tech/ username: vista password: from_secret: gitea_token \ No newline at end of file From 312fa12d04479055167c39a828be8d186c18732d Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:21:52 +0100 Subject: [PATCH 25/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 030c02c..d3e5e1e 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -8,6 +8,7 @@ pipeline: image: woodpeckerci/plugin-docker-buildx:latest secrets: [ dockerhub_token, gitea_token ] repo: vistanarvas/${CI_REPO_NAME},https://git.narvas.tech/vista/${CI_REPO_NAME} + tag: dev settings: logins: - registry: https://index.docker.io/v2/ From 38c5ff32db47b71097ebe3385c01ce7de429a4a7 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:43:14 +0100 Subject: [PATCH 26/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index d3e5e1e..82847e2 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -7,7 +7,7 @@ pipeline: build_and_publish: image: woodpeckerci/plugin-docker-buildx:latest secrets: [ dockerhub_token, gitea_token ] - repo: vistanarvas/${CI_REPO_NAME},https://git.narvas.tech/vista/${CI_REPO_NAME} + repo: vistanarvas/${CI_REPO_NAME},git.narvas.tech/vista/${CI_REPO_NAME} tag: dev settings: logins: From 629627c9325dfb3c221e95d13ecfdceee57a7950 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:43:52 +0100 Subject: [PATCH 27/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 82847e2..7417340 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -11,7 +11,7 @@ pipeline: tag: dev settings: logins: - - registry: https://index.docker.io/v2/ + - registry: https://index.docker.io/ username: vistanarvas password: from_secret: dockerhub_token From de33b0070844a275336171580616ae7c11253e50 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:45:52 +0100 Subject: [PATCH 28/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 7417340..6c8bee2 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -5,17 +5,22 @@ when: pipeline: build_and_publish: - image: woodpeckerci/plugin-docker-buildx:latest - secrets: [ dockerhub_token, gitea_token ] - repo: vistanarvas/${CI_REPO_NAME},git.narvas.tech/vista/${CI_REPO_NAME} - tag: dev + image: woodpeckerci/plugin-docker-buildx settings: - logins: - - registry: https://index.docker.io/ - username: vistanarvas - password: - from_secret: dockerhub_token - - registry: https://git.narvas.tech/ - username: vista - password: - from_secret: gitea_token \ No newline at end of file + username: vistanarvas + password: + from_secret: DOCKERHUB_TOKEN + repo: vistanarvas/${CI_REPO_NAME} + tag: dev + when: + include: [ '.woodpecker/build.yml', 'Dockerfile', 'check.sh' ] + build_and_publish: + image: woodpeckerci/plugin-docker-buildx + settings: + username: vista + password: + from_secret: GITEA_TOKEN + repo: vista/${CI_REPO_NAME} + tag: dev + when: + include: [ '.woodpecker/build.yml', 'Dockerfile', 'check.sh' ] \ No newline at end of file From a8d18c5ea7762066ffa5893fada91e1acf8a2cf8 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:46:53 +0100 Subject: [PATCH 29/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 6c8bee2..78e35c3 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -16,6 +16,7 @@ pipeline: include: [ '.woodpecker/build.yml', 'Dockerfile', 'check.sh' ] build_and_publish: image: woodpeckerci/plugin-docker-buildx + registry: git.narvas.tech settings: username: vista password: From 257808f9f68eca9922f371c3f8ba1dd66f22a0ac Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:50:23 +0100 Subject: [PATCH 30/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 78e35c3..636f440 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -4,7 +4,7 @@ when: include: [ '.woodpecker/build-dev.yml', 'Dockerfile', 'check.sh' ] pipeline: - build_and_publish: + build_and_publish_docker: image: woodpeckerci/plugin-docker-buildx settings: username: vistanarvas @@ -12,16 +12,12 @@ pipeline: from_secret: DOCKERHUB_TOKEN repo: vistanarvas/${CI_REPO_NAME} tag: dev - when: - include: [ '.woodpecker/build.yml', 'Dockerfile', 'check.sh' ] - build_and_publish: + build_and_publish_gitea: image: woodpeckerci/plugin-docker-buildx registry: git.narvas.tech settings: username: vista password: - from_secret: GITEA_TOKEN + from_secret: DOCKERHUB_TOKEN repo: vista/${CI_REPO_NAME} - tag: dev - when: - include: [ '.woodpecker/build.yml', 'Dockerfile', 'check.sh' ] \ No newline at end of file + tag: dev \ No newline at end of file From 8ea218fb69d5fa2c40b1edaf2eb8f3cab504659c Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:52:25 +0100 Subject: [PATCH 31/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 636f440..c2c3999 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -14,7 +14,7 @@ pipeline: tag: dev build_and_publish_gitea: image: woodpeckerci/plugin-docker-buildx - registry: git.narvas.tech + registry: git.narvas.tech/vista/${CI_REPO_NAME}:dev settings: username: vista password: From d6da5c8df6f208b1323890890f630265771c7a30 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:53:42 +0100 Subject: [PATCH 32/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index c2c3999..58fb80d 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -4,20 +4,20 @@ when: include: [ '.woodpecker/build-dev.yml', 'Dockerfile', 'check.sh' ] pipeline: - build_and_publish_docker: - image: woodpeckerci/plugin-docker-buildx - settings: - username: vistanarvas - password: - from_secret: DOCKERHUB_TOKEN - repo: vistanarvas/${CI_REPO_NAME} - tag: dev + # build_and_publish_docker: + # image: woodpeckerci/plugin-docker-buildx + # settings: + # username: vistanarvas + # password: + # from_secret: DOCKERHUB_TOKEN + # repo: vistanarvas/${CI_REPO_NAME} + # tag: dev build_and_publish_gitea: image: woodpeckerci/plugin-docker-buildx - registry: git.narvas.tech/vista/${CI_REPO_NAME}:dev + registry: git.narvas.tech settings: username: vista password: - from_secret: DOCKERHUB_TOKEN + from_secret: GITEA_TOKEN repo: vista/${CI_REPO_NAME} tag: dev \ No newline at end of file From 6dd9032f109c2259b525bcbc27907f7b4629a53f Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 19:55:11 +0100 Subject: [PATCH 33/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 58fb80d..064da9e 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -14,7 +14,7 @@ pipeline: # tag: dev build_and_publish_gitea: image: woodpeckerci/plugin-docker-buildx - registry: git.narvas.tech + registry: https://git.narvas.tech settings: username: vista password: From dd3e15f046e7cf1ab855eaea2348c4f233ed8f75 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 20:02:24 +0100 Subject: [PATCH 34/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 064da9e..55a0c1a 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -14,10 +14,24 @@ pipeline: # tag: dev build_and_publish_gitea: image: woodpeckerci/plugin-docker-buildx - registry: https://git.narvas.tech + registry: git.narvas.tech settings: - username: vista - password: - from_secret: GITEA_TOKEN - repo: vista/${CI_REPO_NAME} - tag: dev \ No newline at end of file + repo: vistanarvas/container-update-checker,git.narvas.tech/vista/container-update-checker + tag: dev + logins: + # Default DockerHub login + - registry: https://index.docker.io/v1/ + username: vistanarvas + password: + from_secret: DOCKERHUB_TOKEN + # Additional Gitea login + - registry: https://git.narvas.tech + username: vista + password: + from_secret: GITEA_TOKEN + # settings: + # username: vista + # password: + # from_secret: GITEA_TOKEN + # repo: vista/${CI_REPO_NAME} + # tag: dev \ No newline at end of file From 5b0467244754526d01e097b141142d67afb33d2a Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 20:13:21 +0100 Subject: [PATCH 35/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 55a0c1a..eb8f962 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -4,14 +4,6 @@ when: include: [ '.woodpecker/build-dev.yml', 'Dockerfile', 'check.sh' ] pipeline: - # build_and_publish_docker: - # image: woodpeckerci/plugin-docker-buildx - # settings: - # username: vistanarvas - # password: - # from_secret: DOCKERHUB_TOKEN - # repo: vistanarvas/${CI_REPO_NAME} - # tag: dev build_and_publish_gitea: image: woodpeckerci/plugin-docker-buildx registry: git.narvas.tech @@ -28,10 +20,4 @@ pipeline: - registry: https://git.narvas.tech username: vista password: - from_secret: GITEA_TOKEN - # settings: - # username: vista - # password: - # from_secret: GITEA_TOKEN - # repo: vista/${CI_REPO_NAME} - # tag: dev \ No newline at end of file + from_secret: GITEA_TOKEN \ No newline at end of file From 94a301bdb26acef8340157a06a5cf2438f97b82c Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 20:36:32 +0100 Subject: [PATCH 36/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index eb8f962..5cb1720 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -9,7 +9,7 @@ pipeline: registry: git.narvas.tech settings: repo: vistanarvas/container-update-checker,git.narvas.tech/vista/container-update-checker - tag: dev + tag: dev,dev logins: # Default DockerHub login - registry: https://index.docker.io/v1/ From 149437608578473e000dd844d4bdc4e762db8f63 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 20:42:27 +0100 Subject: [PATCH 37/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 5cb1720..039ccab 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -8,8 +8,8 @@ pipeline: image: woodpeckerci/plugin-docker-buildx registry: git.narvas.tech settings: - repo: vistanarvas/container-update-checker,git.narvas.tech/vista/container-update-checker - tag: dev,dev + repo: vistanarvas/container-update-checker,git.narvas.tech/vista/container-update-checker:dev + tag: dev logins: # Default DockerHub login - registry: https://index.docker.io/v1/ From e0159d3c5507f400cec827c8bd546cff25c6f2cb Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 20:43:01 +0100 Subject: [PATCH 38/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 039ccab..eb8f962 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -8,7 +8,7 @@ pipeline: image: woodpeckerci/plugin-docker-buildx registry: git.narvas.tech settings: - repo: vistanarvas/container-update-checker,git.narvas.tech/vista/container-update-checker:dev + repo: vistanarvas/container-update-checker,git.narvas.tech/vista/container-update-checker tag: dev logins: # Default DockerHub login From 4f68eb9cd802f6c1c8eb1203ee1f5eb86507f04f Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 20:56:21 +0100 Subject: [PATCH 39/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index eb8f962..db603dc 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -10,6 +10,7 @@ pipeline: settings: repo: vistanarvas/container-update-checker,git.narvas.tech/vista/container-update-checker tag: dev + labels: name=dev logins: # Default DockerHub login - registry: https://index.docker.io/v1/ From bd482175535eeda5a99fc52cf01e84b6150dfae2 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 20:58:01 +0100 Subject: [PATCH 40/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index db603dc..eb8f962 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -10,7 +10,6 @@ pipeline: settings: repo: vistanarvas/container-update-checker,git.narvas.tech/vista/container-update-checker tag: dev - labels: name=dev logins: # Default DockerHub login - registry: https://index.docker.io/v1/ From 4daf73bcb8bd8142667b3d70922dbf957663bbf5 Mon Sep 17 00:00:00 2001 From: vista Date: Mon, 20 Mar 2023 20:58:41 +0100 Subject: [PATCH 41/53] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index eb8f962..2599f9f 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -10,6 +10,7 @@ pipeline: settings: repo: vistanarvas/container-update-checker,git.narvas.tech/vista/container-update-checker tag: dev + auto_tag: false logins: # Default DockerHub login - registry: https://index.docker.io/v1/ From 2fa59436a2b60dafa2ad0124abd6173068f3c7d0 Mon Sep 17 00:00:00 2001 From: vista Date: Tue, 21 Mar 2023 10:50:25 +0100 Subject: [PATCH 42/53] Update 'check.sh' --- check.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/check.sh b/check.sh index 9336dfb..6e7e006 100644 --- a/check.sh +++ b/check.sh @@ -81,6 +81,7 @@ if [ -n "${DOCKER_USERNAME}" ] && [ -n "${DOCKER_PASSWORD}" ]; then HEADER="Authorization: JWT ${TOKEN}" fi +# curl -X 'GET' -H 'accept: application/json' 'https://git.narvas.tech/api/v1/packages/[USER]/container/[REPO]/dev?access_token=[TOKEN]' # compare the update time of the BASE and TARGET images BASE_DATE=$(curl -s -H "${HEADER}" "${BASE_URL}" | jq -r .last_updated | sed 's/T/ /' | sed 's/\..*//' ) From 8345924a368b8e70daa6fb3d0e3d4ef9d234e37f Mon Sep 17 00:00:00 2001 From: vista Date: Tue, 21 Mar 2023 12:51:05 +0100 Subject: [PATCH 43/53] wip [skip ci] --- check.sh | 92 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 68 insertions(+), 24 deletions(-) diff --git a/check.sh b/check.sh index 6e7e006..2b76121 100644 --- a/check.sh +++ b/check.sh @@ -23,52 +23,96 @@ if [ -z "${TARGET}" ]; then exit 1 fi -if [ -z "${REPO_URL}" ]; then - REPO_URL="https://hub.docker.com/v2/repositories" -fi - -if [ -z "${BASE_REPO_URL}" ]; then - BASE_REPO_URL="${REPO_URL}" -fi - -if [ -z "${TARGET_REPO_URL}" ]; then - TARGET_REPO_URL="${REPO_URL}" -fi - -if [ -z "${BASE_REPO_USERNAME}" && -n "${REPO_USERNAME}" ]; then +if [ -z "${BASE_REGISTRY_USERNAME}" && -n "${REGISTRY_USERNAME}" ]; then BASE_REPO_USERNAME="${REPO_USERNAME}" fi -if [ -z "${BASE_REPO_PASSWORD}" && -n "${REPO_PASSWORD}" ]; then +if [ -z "${BASE_REGISTRY_PASSWORD}" && -n "${REGISTRY_PASSWORD}" ]; then BASE_REPO_PASSWORD="${REPO_PASSWORD}" fi - -if [ -z "${TARGET_REPO_USERNAME}" && -n "${REPO_USERNAME}" ]; then +if [ -z "${TARGET_REGISTRY_USERNAME}" && -n "${REGISTRY_USERNAME}" ]; then TARGET_REPO_USERNAME="${REPO_USERNAME}" fi -if [ -z "${TARGET_REPO_PASSWORD}" && -n "${REPO_PASSWORD}" ]; then +if [ -z "${TARGET_REGISTRY_PASSWORD}" && -n "${REGISTRY_PASSWORD}" ]; then BASE_REPO_PASSWORD="${REPO_PASSWORD}" fi +if [ -z "${REGISTRY_API}" ]; then + REGISTRY_API = 'docker' +fi -# add "library/" if its a "official" docker image (it has no username) +if [ -z "${BASE_REGISTRY_API}" ]; then + BASE_REGISTRY_API = '${REGISTRY_API}' +fi + +if [ -z "${TARGET_REGISTRY_API}" ]; then + TARGET_REGISTRY_API = '${REGISTRY_API}' +fi + +if [ -z "${REGISTRY_URL}" ]; then + REGISTRY_URL="https://hub.docker.com/v2" + # repositories +fi + +if [ -z "${BASE_REPO_URL}" ]; then + BASE_REGISTRY_URL="${REPO_URL}" +fi + +if [ -z "${TARGET_REPO_URL}" ]; then + TARGET_REGISTRY_URL="${REPO_URL}" +fi + +# remove trailing / +BASE_REGISTRY_URL="${BASE_REGISTRY_URL%/}" +TARGET_REGISTRY_URL="${TARGET_REGISTRY_URL%/}" + +# add "library/" if its a "official" docker image (no username is provided) echo "${BASE}" | grep -q "/" || BASE="library/${BASE}" echo "${TARGET}" | grep -q "/" || TARGET="library/${TARGET}" -# if no tag is give default to latest +# if no tag is given default to latest echo "${BASE}" | grep -q ":" || BASE="${BASE}:latest" echo "${TARGET}" | grep -q ":" || TARGET="${TARGET}:latest" +# split repo into user reponame and tag +IFS='/:' +read -ra parts <<< "${BASE_REPO}" +BASE_REPO_USER="${parts[0]}" +BASE_REPO_NAME="${parts[1]}" +BASE_REPO_TAG="${parts[2]}" -# move the tag to its own var and remove it from the repo name -BASE_TAG=$(echo "${BASE}" | sed 's/[^:]*://') -TARGET_TAG=$(echo "${TARGET}" | sed 's/[^:]*://') +read -ra parts <<< "${TARGET_REPO}" +TARGET_REPO_USER="${parts[0]}" +TARGET_REPO_NAME="${parts[1]}" +TARGET_REPO_TAG="${parts[2]}" -BASE_REPO=$(echo "${BASE}" | sed 's/:.*//') -TARGET_REPO=$(echo "${TARGET}" | sed 's/:.*//') +if [ -n "${BASE_REGISTRY_USERNAME}" && -n "${BASE_REGISTRY_PASSWORD}" \ ] +# make a shared login header if REGISTRY_API REGISTRY_USERNAME and REGISTRY_PASSWORD are the same for BASE and TARGET +if [ "${BASE_REGISTRY_API}" == "${TARGET_REGISTRY_API}" \ + && "${BASE_REGISTRY_USERNAME}" == "${TARGET_REGISTRY_USERNAME}" \ + && "${BASE_REGISTRY_PASSWORD}" == "${TARGET_REGISTRY_PASSWORD}" \ + && "${BASE_REGISTRY_URL}" == "${TARGET_REGISTRY_URL}" \ + && -n "${BASE_REGISTRY_USERNAME}" \ + && -n "${BASE_REGISTRY_PASSWORD}" \ + ]; then + if [ "${BASE_REGISTRY_API}" == "docker" ]; then + TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${BASE_REGISTRY_USERNAME}\", \"password\": \"${BASE_REGISTRY_PASSWORD}\"}" ${BASE_REGISTRY_URL}/users/login/ | jq -r .token) + BASE_HEADER="Authorization: JWT ${TOKEN}" + TARGET_HEADER="Authorization: JWT ${TOKEN}" + elif [ "${BASE_REGISTRY_API}" == "gitea" ]; then + BASE_HEADER="Authorization: token ${BASE_REGISTRY_PASSWORD}" + TARGET_HEADER="Authorization: token ${TARGET_REGISTRY_PASSWORD}" + fi +fi + +if [ "${BASE_REGISTRY_API}" == "docker" ]; then + BASE_URL="${BASE_REPO_URL}/${BASE_REPO_USER}/${BASE_REPO_NAME}/tags/${BASE_REPO_TAG}" +elif [ "${BASE_REGISTRY_API}" == "gitea" ]; then + +fi # build the url to the repo BASE_URL="${BASE_REPO_URL}/${BASE_REPO}/tags/${BASE_TAG}" From 33c30e47d7754c208de766dfa63670a768822f87 Mon Sep 17 00:00:00 2001 From: vista Date: Thu, 23 Mar 2023 19:36:35 +0100 Subject: [PATCH 44/53] Update 'check.sh' --- check.sh | 55 ++++++++++++++++++++++++------------------------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/check.sh b/check.sh index 2b76121..14b0941 100644 --- a/check.sh +++ b/check.sh @@ -88,45 +88,38 @@ TARGET_REPO_USER="${parts[0]}" TARGET_REPO_NAME="${parts[1]}" TARGET_REPO_TAG="${parts[2]}" -if [ -n "${BASE_REGISTRY_USERNAME}" && -n "${BASE_REGISTRY_PASSWORD}" \ ] -# make a shared login header if REGISTRY_API REGISTRY_USERNAME and REGISTRY_PASSWORD are the same for BASE and TARGET -if [ "${BASE_REGISTRY_API}" == "${TARGET_REGISTRY_API}" \ - && "${BASE_REGISTRY_USERNAME}" == "${TARGET_REGISTRY_USERNAME}" \ - && "${BASE_REGISTRY_PASSWORD}" == "${TARGET_REGISTRY_PASSWORD}" \ - && "${BASE_REGISTRY_URL}" == "${TARGET_REGISTRY_URL}" \ - && -n "${BASE_REGISTRY_USERNAME}" \ - && -n "${BASE_REGISTRY_PASSWORD}" \ - ]; then - if [ "${BASE_REGISTRY_API}" == "docker" ]; then +BASE_HEADER="" +if [ "${BASE_REGISTRY_API}" == 'docker' ];then + if [ -n "${BASE_REGISTRY_USERNAME}" && -n "${BASE_REGISTRY_PASSWORD}" ]; then TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${BASE_REGISTRY_USERNAME}\", \"password\": \"${BASE_REGISTRY_PASSWORD}\"}" ${BASE_REGISTRY_URL}/users/login/ | jq -r .token) BASE_HEADER="Authorization: JWT ${TOKEN}" - TARGET_HEADER="Authorization: JWT ${TOKEN}" - elif [ "${BASE_REGISTRY_API}" == "gitea" ]; then + fi + BASE_URL="${BASE_REPO_URL}/${BASE_REPO_USER}/${BASE_REPO_NAME}/tags/${BASE_REPO_TAG}" + +elif [ "${BASE_REGISTRY_API}" == 'gitea' ];then + if [ -n "${BASE_REGISTRY_PASSWORD}" ]; then BASE_HEADER="Authorization: token ${BASE_REGISTRY_PASSWORD}" + fi + BASE_URL="${BASE_REPO_URL}/api/v1/packages/${BASE_REPO_USER}/container/${BASE_REPO_NAME}/${BASE_REPO_TAG}" +fi + + +TARGET_HEADER="" +if [ "${TARGET_REGISTRY_API}" == 'docker' ];then + if [ -n "${TARGET_REGISTRY_USERNAME}" && -n "${TARGET_REGISTRY_PASSWORD}" ]; then + TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${TARGET_REGISTRY_USERNAME}\", \"password\": \"${TARGET_REGISTRY_PASSWORD}\"}" ${TARGET_REGISTRY_URL}/users/login/ | jq -r .token) + TARGET_HEADER="Authorization: JWT ${TOKEN}" + fi + TARGET_URL="${TARGET_REPO_URL}/${TARGET_REPO_USER}/${TARGET_REPO_NAME}/tags/${TARGET_REPO_TAG}" + +elif [ "${TARGET_REGISTRY_API}" == 'gitea' ];then + if [ -n "${TARGET_REGISTRY_PASSWORD}" ]; then TARGET_HEADER="Authorization: token ${TARGET_REGISTRY_PASSWORD}" fi + TARGET_URL="${TARGET_REPO_URL}/api/v1/packages/${TARGET_REPO_USER}/container/${TARGET_REPO_NAME}/${TARGET_REPO_TAG}" fi -if [ "${BASE_REGISTRY_API}" == "docker" ]; then - BASE_URL="${BASE_REPO_URL}/${BASE_REPO_USER}/${BASE_REPO_NAME}/tags/${BASE_REPO_TAG}" -elif [ "${BASE_REGISTRY_API}" == "gitea" ]; then - -fi - -# build the url to the repo -BASE_URL="${BASE_REPO_URL}/${BASE_REPO}/tags/${BASE_TAG}" -TARGET_URL="${TARGET_REPO_URL}/${TARGET_REPO}/tags/${TARGET_TAG}" - -# login if credentias are passed -HEADER="" -if [ -n "${DOCKER_USERNAME}" ] && [ -n "${DOCKER_PASSWORD}" ]; then - TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'"${DOCKER_USERNAME}"'", "password": "'"${DOCKER_PASSWORD}"'"}' https://hub.docker.com/v2/users/login/ | jq -r .token) - HEADER="Authorization: JWT ${TOKEN}" -fi - -# curl -X 'GET' -H 'accept: application/json' 'https://git.narvas.tech/api/v1/packages/[USER]/container/[REPO]/dev?access_token=[TOKEN]' - # compare the update time of the BASE and TARGET images BASE_DATE=$(curl -s -H "${HEADER}" "${BASE_URL}" | jq -r .last_updated | sed 's/T/ /' | sed 's/\..*//' ) TARGET_DATE=$(curl -s -H "${HEADER}" "${TARGET_URL}" | jq -r .last_updated | sed 's/T/ /' | sed 's/\..*//' ) From d63050c1c5bc835d4a3a2a2bc129e154e6acbc80 Mon Sep 17 00:00:00 2001 From: vista Date: Thu, 23 Mar 2023 19:57:24 +0100 Subject: [PATCH 45/53] Update 'check.sh' fixed errors using shellcheck https://www.shellcheck.net --- check.sh | 71 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/check.sh b/check.sh index 14b0941..388ae96 100644 --- a/check.sh +++ b/check.sh @@ -23,32 +23,32 @@ if [ -z "${TARGET}" ]; then exit 1 fi -if [ -z "${BASE_REGISTRY_USERNAME}" && -n "${REGISTRY_USERNAME}" ]; then - BASE_REPO_USERNAME="${REPO_USERNAME}" +if [ -z "${BASE_REGISTRY_USERNAME}" ] && [ -n "${REGISTRY_USERNAME}" ]; then + BASE_REGISTRY_USERNAME="${REPO_USERNAME}" fi -if [ -z "${BASE_REGISTRY_PASSWORD}" && -n "${REGISTRY_PASSWORD}" ]; then - BASE_REPO_PASSWORD="${REPO_PASSWORD}" +if [ -z "${BASE_REGISTRY_PASSWORD}" ] && [ -n "${REGISTRY_PASSWORD}" ]; then + BASE_REGISTRY_PASSWORD="${REPO_PASSWORD}" fi -if [ -z "${TARGET_REGISTRY_USERNAME}" && -n "${REGISTRY_USERNAME}" ]; then - TARGET_REPO_USERNAME="${REPO_USERNAME}" +if [ -z "${TARGET_REGISTRY_USERNAME}" ] && [ -n "${REGISTRY_USERNAME}" ]; then + TARGET_REGISTRY_USERNAME="${REPO_USERNAME}" fi -if [ -z "${TARGET_REGISTRY_PASSWORD}" && -n "${REGISTRY_PASSWORD}" ]; then - BASE_REPO_PASSWORD="${REPO_PASSWORD}" +if [ -z "${TARGET_REGISTRY_PASSWORD}" ] && [ -n "${REGISTRY_PASSWORD}" ]; then + TARGET_REGISTRY_PASSWORD="${REPO_PASSWORD}" fi if [ -z "${REGISTRY_API}" ]; then - REGISTRY_API = 'docker' + REGISTRY_API='docker' fi if [ -z "${BASE_REGISTRY_API}" ]; then - BASE_REGISTRY_API = '${REGISTRY_API}' + BASE_REGISTRY_API="${REGISTRY_API}" fi if [ -z "${TARGET_REGISTRY_API}" ]; then - TARGET_REGISTRY_API = '${REGISTRY_API}' + TARGET_REGISTRY_API="${REGISTRY_API}" fi if [ -z "${REGISTRY_URL}" ]; then @@ -78,26 +78,39 @@ echo "${TARGET}" | grep -q ":" || TARGET="${TARGET}:latest" # split repo into user reponame and tag IFS='/:' -read -ra parts <<< "${BASE_REPO}" -BASE_REPO_USER="${parts[0]}" -BASE_REPO_NAME="${parts[1]}" -BASE_REPO_TAG="${parts[2]}" +read -r BASE_REPO +set -- "$BASE_REPO" +BASE_REPO_USER="$1" +BASE_REPO_NAME="$2" +BASE_REPO_TAG="$3" -read -ra parts <<< "${TARGET_REPO}" -TARGET_REPO_USER="${parts[0]}" -TARGET_REPO_NAME="${parts[1]}" -TARGET_REPO_TAG="${parts[2]}" +read -r TARGET_REPO +set -- "$TARGET_REPO" +TARGET_REPO_USER="$1" +TARGET_REPO_NAME="$2" +TARGET_REPO_TAG="$3" + +# IFS='/:' +# read -ra parts <<< "${BASE_REPO}" +# BASE_REPO_USER="${parts[0]}" +# BASE_REPO_NAME="${parts[1]}" +# BASE_REPO_TAG="${parts[2]}" + +# read -ra parts <<< "${TARGET_REPO}" +# TARGET_REPO_USER="${parts[0]}" +# TARGET_REPO_NAME="${parts[1]}" +# TARGET_REPO_TAG="${parts[2]}" BASE_HEADER="" -if [ "${BASE_REGISTRY_API}" == 'docker' ];then - if [ -n "${BASE_REGISTRY_USERNAME}" && -n "${BASE_REGISTRY_PASSWORD}" ]; then - TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${BASE_REGISTRY_USERNAME}\", \"password\": \"${BASE_REGISTRY_PASSWORD}\"}" ${BASE_REGISTRY_URL}/users/login/ | jq -r .token) +if [ "${BASE_REGISTRY_API}" = 'docker' ];then + if [ -n "${BASE_REGISTRY_USERNAME}" ] && [ -n "${BASE_REGISTRY_PASSWORD}" ]; then + TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${BASE_REGISTRY_USERNAME}\", \"password\": \"${BASE_REGISTRY_PASSWORD}\"}" "${BASE_REGISTRY_URL}/users/login/" | jq -r .token) BASE_HEADER="Authorization: JWT ${TOKEN}" fi BASE_URL="${BASE_REPO_URL}/${BASE_REPO_USER}/${BASE_REPO_NAME}/tags/${BASE_REPO_TAG}" -elif [ "${BASE_REGISTRY_API}" == 'gitea' ];then +elif [ "${BASE_REGISTRY_API}" = 'gitea' ];then if [ -n "${BASE_REGISTRY_PASSWORD}" ]; then BASE_HEADER="Authorization: token ${BASE_REGISTRY_PASSWORD}" fi @@ -106,14 +119,14 @@ fi TARGET_HEADER="" -if [ "${TARGET_REGISTRY_API}" == 'docker' ];then - if [ -n "${TARGET_REGISTRY_USERNAME}" && -n "${TARGET_REGISTRY_PASSWORD}" ]; then - TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${TARGET_REGISTRY_USERNAME}\", \"password\": \"${TARGET_REGISTRY_PASSWORD}\"}" ${TARGET_REGISTRY_URL}/users/login/ | jq -r .token) +if [ "${TARGET_REGISTRY_API}" = 'docker' ];then + if [ -n "${TARGET_REGISTRY_USERNAME}" ] && [ -n "${TARGET_REGISTRY_PASSWORD}" ]; then + TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${TARGET_REGISTRY_USERNAME}\", \"password\": \"${TARGET_REGISTRY_PASSWORD}\"}" "${TARGET_REGISTRY_URL}/users/login/" | jq -r .token) TARGET_HEADER="Authorization: JWT ${TOKEN}" fi TARGET_URL="${TARGET_REPO_URL}/${TARGET_REPO_USER}/${TARGET_REPO_NAME}/tags/${TARGET_REPO_TAG}" -elif [ "${TARGET_REGISTRY_API}" == 'gitea' ];then +elif [ "${TARGET_REGISTRY_API}" = 'gitea' ];then if [ -n "${TARGET_REGISTRY_PASSWORD}" ]; then TARGET_HEADER="Authorization: token ${TARGET_REGISTRY_PASSWORD}" fi @@ -121,8 +134,8 @@ elif [ "${TARGET_REGISTRY_API}" == 'gitea' ];then fi # compare the update time of the BASE and TARGET images -BASE_DATE=$(curl -s -H "${HEADER}" "${BASE_URL}" | jq -r .last_updated | sed 's/T/ /' | sed 's/\..*//' ) -TARGET_DATE=$(curl -s -H "${HEADER}" "${TARGET_URL}" | jq -r .last_updated | sed 's/T/ /' | sed 's/\..*//' ) +BASE_DATE=$(curl -s -H "${BASE_HEADER}" "${BASE_URL}" | jq -r .last_updated | sed 's/T/ /' | sed 's/\..*//' ) +TARGET_DATE=$(curl -s -H "${TARGET_HEADER}" "${TARGET_URL}" | jq -r .last_updated | sed 's/T/ /' | sed 's/\..*//' ) BASE_TIMESTAMP=$(date -d "${BASE_DATE}" +%s) TARGET_TIMESTAMP=$(date -d "${TARGET_DATE}" +%s) From fe4be4dd2504a5ed2f5d7273b325577a7a8a4b09 Mon Sep 17 00:00:00 2001 From: vista Date: Thu, 23 Mar 2023 20:04:39 +0100 Subject: [PATCH 46/53] Update 'check.sh' --- check.sh | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/check.sh b/check.sh index 388ae96..fc1288a 100644 --- a/check.sh +++ b/check.sh @@ -77,30 +77,13 @@ echo "${BASE}" | grep -q ":" || BASE="${BASE}:latest" echo "${TARGET}" | grep -q ":" || TARGET="${TARGET}:latest" # split repo into user reponame and tag -IFS='/:' -read -r BASE_REPO -set -- "$BASE_REPO" -BASE_REPO_USER="$1" -BASE_REPO_NAME="$2" -BASE_REPO_TAG="$3" - -read -r TARGET_REPO -set -- "$TARGET_REPO" -TARGET_REPO_USER="$1" -TARGET_REPO_NAME="$2" -TARGET_REPO_TAG="$3" - -# IFS='/:' -# read -ra parts <<< "${BASE_REPO}" -# BASE_REPO_USER="${parts[0]}" -# BASE_REPO_NAME="${parts[1]}" -# BASE_REPO_TAG="${parts[2]}" - -# read -ra parts <<< "${TARGET_REPO}" -# TARGET_REPO_USER="${parts[0]}" -# TARGET_REPO_NAME="${parts[1]}" -# TARGET_REPO_TAG="${parts[2]}" +BASE_REPO_USER=$(echo "$BASE_REPO" | cut -d'/' -f1) +BASE_REPO_NAME=$(echo "$BASE_REPO" | cut -d'/' -f2 | cut -d':' -f1) +BASE_REPO_TAG=$(echo "$BASE_REPO" | cut -d':' -f2) +TARGET_REPO_USER=$(echo "$TARGET_REPO" | cut -d'/' -f1) +TARGET_REPO_NAME=$(echo "$TARGET_REPO" | cut -d'/' -f2 | cut -d':' -f1) +TARGET_REPO_TAG=$(echo "$TARGET_REPO" | cut -d':' -f2) BASE_HEADER="" if [ "${BASE_REGISTRY_API}" = 'docker' ];then From 3b21bb24479732f27106dddef2fb63f93bbd37b1 Mon Sep 17 00:00:00 2001 From: vista Date: Thu, 23 Mar 2023 20:13:19 +0100 Subject: [PATCH 47/53] Update 'check.sh' --- check.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/check.sh b/check.sh index fc1288a..a345546 100644 --- a/check.sh +++ b/check.sh @@ -56,12 +56,12 @@ if [ -z "${REGISTRY_URL}" ]; then # repositories fi -if [ -z "${BASE_REPO_URL}" ]; then - BASE_REGISTRY_URL="${REPO_URL}" +if [ -z "${BASE_REGISTRY_URL}" ]; then + BASE_REGISTRY_URL="${REGISTRY_URL}" fi -if [ -z "${TARGET_REPO_URL}" ]; then - TARGET_REGISTRY_URL="${REPO_URL}" +if [ -z "${TARGET_REGISTRY_URL}" ]; then + TARGET_REGISTRY_URL="${REGISTRY_URL}" fi # remove trailing / @@ -77,13 +77,13 @@ echo "${BASE}" | grep -q ":" || BASE="${BASE}:latest" echo "${TARGET}" | grep -q ":" || TARGET="${TARGET}:latest" # split repo into user reponame and tag -BASE_REPO_USER=$(echo "$BASE_REPO" | cut -d'/' -f1) -BASE_REPO_NAME=$(echo "$BASE_REPO" | cut -d'/' -f2 | cut -d':' -f1) -BASE_REPO_TAG=$(echo "$BASE_REPO" | cut -d':' -f2) +BASE_REPO_USER=$(echo "$BASE" | cut -d'/' -f1) +BASE_REPO_NAME=$(echo "$BASE" | cut -d'/' -f2 | cut -d':' -f1) +BASE_REPO_TAG=$(echo "$BASE" | cut -d':' -f2) -TARGET_REPO_USER=$(echo "$TARGET_REPO" | cut -d'/' -f1) -TARGET_REPO_NAME=$(echo "$TARGET_REPO" | cut -d'/' -f2 | cut -d':' -f1) -TARGET_REPO_TAG=$(echo "$TARGET_REPO" | cut -d':' -f2) +TARGET_REPO_USER=$(echo "$TARGET" | cut -d'/' -f1) +TARGET_REPO_NAME=$(echo "$TARGET" | cut -d'/' -f2 | cut -d':' -f1) +TARGET_REPO_TAG=$(echo "$TARGET" | cut -d':' -f2) BASE_HEADER="" if [ "${BASE_REGISTRY_API}" = 'docker' ];then @@ -91,13 +91,13 @@ if [ "${BASE_REGISTRY_API}" = 'docker' ];then TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${BASE_REGISTRY_USERNAME}\", \"password\": \"${BASE_REGISTRY_PASSWORD}\"}" "${BASE_REGISTRY_URL}/users/login/" | jq -r .token) BASE_HEADER="Authorization: JWT ${TOKEN}" fi - BASE_URL="${BASE_REPO_URL}/${BASE_REPO_USER}/${BASE_REPO_NAME}/tags/${BASE_REPO_TAG}" + BASE_URL="${BASE_REGISTRY_URL}/${BASE_REPO_USER}/${BASE_REPO_NAME}/tags/${BASE_REPO_TAG}" elif [ "${BASE_REGISTRY_API}" = 'gitea' ];then if [ -n "${BASE_REGISTRY_PASSWORD}" ]; then BASE_HEADER="Authorization: token ${BASE_REGISTRY_PASSWORD}" fi - BASE_URL="${BASE_REPO_URL}/api/v1/packages/${BASE_REPO_USER}/container/${BASE_REPO_NAME}/${BASE_REPO_TAG}" + BASE_URL="${BASE_REGISTRY_URL}/api/v1/packages/${BASE_REPO_USER}/container/${BASE_REPO_NAME}/${BASE_REPO_TAG}" fi @@ -107,13 +107,13 @@ if [ "${TARGET_REGISTRY_API}" = 'docker' ];then TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${TARGET_REGISTRY_USERNAME}\", \"password\": \"${TARGET_REGISTRY_PASSWORD}\"}" "${TARGET_REGISTRY_URL}/users/login/" | jq -r .token) TARGET_HEADER="Authorization: JWT ${TOKEN}" fi - TARGET_URL="${TARGET_REPO_URL}/${TARGET_REPO_USER}/${TARGET_REPO_NAME}/tags/${TARGET_REPO_TAG}" + TARGET_URL="${TARGET_REGISTRY_URL}/${TARGET_REPO_USER}/${TARGET_REPO_NAME}/tags/${TARGET_REPO_TAG}" elif [ "${TARGET_REGISTRY_API}" = 'gitea' ];then if [ -n "${TARGET_REGISTRY_PASSWORD}" ]; then TARGET_HEADER="Authorization: token ${TARGET_REGISTRY_PASSWORD}" fi - TARGET_URL="${TARGET_REPO_URL}/api/v1/packages/${TARGET_REPO_USER}/container/${TARGET_REPO_NAME}/${TARGET_REPO_TAG}" + TARGET_URL="${TARGET_REGISTRY_URL}/api/v1/packages/${TARGET_REPO_USER}/container/${TARGET_REPO_NAME}/${TARGET_REPO_TAG}" fi # compare the update time of the BASE and TARGET images From bbb9cb8d3dd5ed7caadf413f5305a56b8d4367d6 Mon Sep 17 00:00:00 2001 From: vista Date: Thu, 23 Mar 2023 20:21:03 +0100 Subject: [PATCH 48/53] Update 'check.sh' --- check.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/check.sh b/check.sh index a345546..d9816a9 100644 --- a/check.sh +++ b/check.sh @@ -52,8 +52,7 @@ if [ -z "${TARGET_REGISTRY_API}" ]; then fi if [ -z "${REGISTRY_URL}" ]; then - REGISTRY_URL="https://hub.docker.com/v2" - # repositories + REGISTRY_URL="https://hub.docker.com" fi if [ -z "${BASE_REGISTRY_URL}" ]; then @@ -91,7 +90,7 @@ if [ "${BASE_REGISTRY_API}" = 'docker' ];then TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${BASE_REGISTRY_USERNAME}\", \"password\": \"${BASE_REGISTRY_PASSWORD}\"}" "${BASE_REGISTRY_URL}/users/login/" | jq -r .token) BASE_HEADER="Authorization: JWT ${TOKEN}" fi - BASE_URL="${BASE_REGISTRY_URL}/${BASE_REPO_USER}/${BASE_REPO_NAME}/tags/${BASE_REPO_TAG}" + BASE_URL="${BASE_REGISTRY_URL}/v2/repositories/${BASE_REPO_USER}/${BASE_REPO_NAME}/tags/${BASE_REPO_TAG}" elif [ "${BASE_REGISTRY_API}" = 'gitea' ];then if [ -n "${BASE_REGISTRY_PASSWORD}" ]; then @@ -107,7 +106,7 @@ if [ "${TARGET_REGISTRY_API}" = 'docker' ];then TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${TARGET_REGISTRY_USERNAME}\", \"password\": \"${TARGET_REGISTRY_PASSWORD}\"}" "${TARGET_REGISTRY_URL}/users/login/" | jq -r .token) TARGET_HEADER="Authorization: JWT ${TOKEN}" fi - TARGET_URL="${TARGET_REGISTRY_URL}/${TARGET_REPO_USER}/${TARGET_REPO_NAME}/tags/${TARGET_REPO_TAG}" + TARGET_URL="${TARGET_REGISTRY_URL}/v2/repositories/${TARGET_REPO_USER}/${TARGET_REPO_NAME}/tags/${TARGET_REPO_TAG}" elif [ "${TARGET_REGISTRY_API}" = 'gitea' ];then if [ -n "${TARGET_REGISTRY_PASSWORD}" ]; then From a7ee8446cbb1b2e92ce5955ff7c08254e5708d16 Mon Sep 17 00:00:00 2001 From: vista Date: Thu, 23 Mar 2023 20:44:41 +0100 Subject: [PATCH 49/53] Update 'check.sh' [skip ci] --- check.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/check.sh b/check.sh index d9816a9..bd861d5 100644 --- a/check.sh +++ b/check.sh @@ -115,12 +115,22 @@ elif [ "${TARGET_REGISTRY_API}" = 'gitea' ];then TARGET_URL="${TARGET_REGISTRY_URL}/api/v1/packages/${TARGET_REPO_USER}/container/${TARGET_REPO_NAME}/${TARGET_REPO_TAG}" fi -# compare the update time of the BASE and TARGET images -BASE_DATE=$(curl -s -H "${BASE_HEADER}" "${BASE_URL}" | jq -r .last_updated | sed 's/T/ /' | sed 's/\..*//' ) -TARGET_DATE=$(curl -s -H "${TARGET_HEADER}" "${TARGET_URL}" | jq -r .last_updated | sed 's/T/ /' | sed 's/\..*//' ) -BASE_TIMESTAMP=$(date -d "${BASE_DATE}" +%s) -TARGET_TIMESTAMP=$(date -d "${TARGET_DATE}" +%s) +# compare the update time of the BASE and TARGET images +if [ "${BASE_REGISTRY_API}" = 'docker' ];then + BASE_DATE=$(curl -s -H "${BASE_HEADER}" "${BASE_URL}" | jq -r .last_updated) +elif [ "${BASE_REGISTRY_API}" = 'gitea' ];then + BASE_DATE=$(curl -s -H "${BASE_HEADER}" "${BASE_URL}" | jq -r .created_at) +fi + +if [ "${TARGET_REGISTRY_API}" = 'docker' ];then + TARGET_DATE=$(curl -s -H "${TARGET_HEADER}" "${TARGET_URL}" | jq -r .last_updated) +elif [ "${TARGET_REGISTRY_API}" = 'gitea' ];then + TARGET_DATE=$(curl -s -H "${TARGET_HEADER}" "${TARGET_URL}" | jq -r .created_at) +fi + +BASE_TIMESTAMP=$(dateconv --format="%s" "${BASE_DATE}") +TARGET_TIMESTAMP=$(dateconv --format="%s" "${TARGET_DATE}") CLEAN_EXIT=true From 79ef9a5d2d312e08f74a74ecf1f789781f8a7575 Mon Sep 17 00:00:00 2001 From: vista Date: Thu, 23 Mar 2023 20:46:27 +0100 Subject: [PATCH 50/53] Update 'Dockerfile' --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 534e8c1..b6b50e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:latest -RUN apk add curl jq +RUN apk add --no-cache curl jq dateutils COPY check.sh /usr/local/bin/check RUN chmod +x /usr/local/bin/check From f00364177f21a427e65f52c4ae6d8c1af59fdeee Mon Sep 17 00:00:00 2001 From: vista Date: Thu, 23 Mar 2023 22:04:04 +0100 Subject: [PATCH 51/53] Update 'check.sh' --- check.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/check.sh b/check.sh index bd861d5..05aab74 100644 --- a/check.sh +++ b/check.sh @@ -23,6 +23,20 @@ if [ -z "${TARGET}" ]; then exit 1 fi +if [ -z "${REGISTRY_USERNAME}" ] && [ -n "${DOCKER_USERNAME}" ]; then + REGISTRY_USERNAME="${DOCKER_USERNAME}" + echo "WARNING: DOCKER_USERNAME is deprecated and will be removed in the next version" + echo "you should switch to using REGISTRY_USERNAME" + echo "see the documentation for more info https://git.narvas.tech/vista/container-update-checker" +fi + +if [ -z "${REGISTRY_PASSWORD}" ] && [ -n "${DOCKER_PASSWORD}" ]; then + REGISTRY_PASSWORD="${DOCKER_PASSWORD}" + echo "WARNING: DOCKER_PASSWORD is deprecated and will be removed in the next version" + echo "you should switch to using REGISTRY_PASSWORD" + echo "see the documentation for more info https://git.narvas.tech/vista/container-update-checker" +fi + if [ -z "${BASE_REGISTRY_USERNAME}" ] && [ -n "${REGISTRY_USERNAME}" ]; then BASE_REGISTRY_USERNAME="${REPO_USERNAME}" fi From 1ba91a85c74b50d867e43e304305c709eb1f282b Mon Sep 17 00:00:00 2001 From: vista Date: Thu, 23 Mar 2023 22:17:43 +0100 Subject: [PATCH 52/53] Update 'README.md' --- README.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c1a4e6c..b49f690 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,31 @@ # container-update-checker +[![status-badge](https://woodpecker.narvas.tech/api/badges/vista/container-update-checker/status.svg)](https://woodpecker.narvas.tech/vista/container-update-checker) check if a container needs rebuilding -[![status-badge](https://woodpecker.narvas.tech/api/badges/vista/container-update-checker/status.svg)](https://woodpecker.narvas.tech/vista/container-update-checker) + +## Environment variables +| Name | Comment +|-------------------|----------- +| BASE | the image the Dockerfile is based on +| TARGET | the image thats based of `BASE` +| REGISTRY_USERNAME | the username for logging in into the registry
this is only requered of private repos +| REGISTRY_PASSWORD | the password for logging in into the registry
(*you probaly want to use a token here*) +| REGISTRY_API | the type of registry valid options are `docker` and `gitea`
Default: `docker` +| REGISTRY_URL | the url to the registry
Default: `https://hub.docker.com` +| BASE_REGISTRY_USERNAME | if left empty `REGISTRY_USERNAME` is used +| BASE_REGISTRY_PASSWORD | if left empty `REGISTRY_PASSWORD` is used +| BASE_REGISTRY_API | if left empty `REGISTRY_API` is used +| BASE_REGISTRY_URL | if left empty `REGISTRY_URL` is used +| TARGET_REGISTRY_USERNAME | if left empty `REGISTRY_USERNAME` is used +| TARGET_REGISTRY_PASSWORD | if left empty `REGISTRY_PASSWORD` is used +| TARGET_REGISTRY_API | if left empty `REGISTRY_API` is used +| TARGET_REGISTRY_URL | if left empty `REGISTRY_URL` is used + + +## Exit codes + +| State | Exit code | Comment +|-------------------------------------|-----------|-------- +| `BASE` is more recent than `TARGET` | 0 | An update is needed +| `TARGET` is more recent than `BASE` | 1 | No update is needed
(*the pipeline wil "fail" but that is wat we want* ) +| An error occured | 0 | So the pipeline can continue \ No newline at end of file From 10e171369cf0d5db271a9a0a5aeb03e02ad58f90 Mon Sep 17 00:00:00 2001 From: vista Date: Thu, 23 Mar 2023 22:31:10 +0100 Subject: [PATCH 53/53] fix: confict --- README.md | 2 +- check.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b49f690..5a4f894 100644 --- a/README.md +++ b/README.md @@ -28,4 +28,4 @@ check if a container needs rebuilding |-------------------------------------|-----------|-------- | `BASE` is more recent than `TARGET` | 0 | An update is needed | `TARGET` is more recent than `BASE` | 1 | No update is needed
(*the pipeline wil "fail" but that is wat we want* ) -| An error occured | 0 | So the pipeline can continue \ No newline at end of file +| An error occured | 0 | So the pipeline can continue diff --git a/check.sh b/check.sh index 05aab74..de44711 100644 --- a/check.sh +++ b/check.sh @@ -154,4 +154,4 @@ if [ "$BASE_TIMESTAMP" -le "$TARGET_TIMESTAMP" ]; then fi echo "$TARGET needs updating" -exit 0 \ No newline at end of file +exit 0