From ee332a3b4d6e611537bf68591f2a4c440e56e18e Mon Sep 17 00:00:00 2001 From: swissbuechi Date: Tue, 31 Oct 2023 15:48:14 +0100 Subject: [PATCH 1/3] Added support for ghcr.io public images --- bin/pincher.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/bin/pincher.sh b/bin/pincher.sh index fbf3f1f..ee0e151 100755 --- a/bin/pincher.sh +++ b/bin/pincher.sh @@ -126,6 +126,27 @@ do [ -n "$latest_version_in_registry" ] && versions_magic done +# github ghcr +versions_ghcr=$(yq '.services[].image' ./*compose*.y* | grep ghcr.io | sort | uniq) +for version in $versions_ghcr +do + latest_version_in_registry="" + + [[ $version =~ ghcr.io\/(.*)\:(.*) ]] + image=${BASH_REMATCH[1]} + v_rematched=${BASH_REMATCH[2]} + echo "image: $image, v: $v_rematched" + + # TODO: Private repos require authentication with a PAT or github token + # ghcr_token=$(echo $GITHUB_TOKEN | base64) + + ghcr_token=$(curl -s https://ghcr.io/token\?scope\="repository:$image:pull" | jq -r .token) + latest_version_in_registry="$(curl -H "Authorization: Bearer ${ghcr_token}" -s https://ghcr.io/v2/$image/tags/list | jq -r '.tags[]' | sort -V -t. -k1,1 -k2,2 -k3,3 | grep -oP '^v?[0-9]+\.[0-9]+\.[0-9]+$' | tail -n 1)" + + # the magic + [ -n "$latest_version_in_registry" ] && versions_magic +done + # considerations "how to edit/contribute" # add each new registry in a separated block loop as per the existing ones # authentication happens via env_vars in the action block if required From 0531b68adc903328c32d11d41b8dc4c95c6721ae Mon Sep 17 00:00:00 2001 From: swissbuechi Date: Tue, 31 Oct 2023 15:56:26 +0100 Subject: [PATCH 2/3] Added ghcr documentation --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9256103..65e0899 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ jobs: - `docker.io/somecompany/theimage:x.x.x` (ie, docker.io/grafana/grafana:10.0.1) - `mcr.microsoft.com/part/theimage:x.x.x` (ie, mcr.microsoft.com/azure-cli:2.50.0) - `gcr.io/project/image:x.x.x` (ie, gcr.io/cadvisor/cadvisor:v0.47.1) + - `ghcr.io/username/image:x.x.x` (ie, ghcr.io/swissbuechi/one-time-secret:1.0.10) ## what for: @@ -65,6 +66,7 @@ jobs: - dockerhub - microsoft mcr - google gcr +- github packages ghcr (public images) - other? open an issue or open pr ## what does it look like From f78ee60fe8f8e3e7ad845fa61686adb1b235e8a3 Mon Sep 17 00:00:00 2001 From: swissbuechi Date: Tue, 31 Oct 2023 18:29:43 +0100 Subject: [PATCH 3/3] bump VERSION file to v0.2.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a1c2c6a..81fd7ba 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.1.1 \ No newline at end of file +v0.2.0 \ No newline at end of file