From fbb8f69bf56e6561f1731590fa2351dcdb8b3950 Mon Sep 17 00:00:00 2001 From: William Young Date: Wed, 30 Mar 2022 19:54:40 +0200 Subject: [PATCH] Initial build --- Containerfile | 5 +++++ check_all.sh | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 Containerfile create mode 100755 check_all.sh diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..9061482 --- /dev/null +++ b/Containerfile @@ -0,0 +1,5 @@ +FROM codycode/okd-tools:4.10.0 +RUN apk --no-cache add zsh jq git +COPY check_all.sh . +RUN chmod +x check_all.sh +CMD ./check_all.sh diff --git a/check_all.sh b/check_all.sh new file mode 100755 index 0000000..a5a130a --- /dev/null +++ b/check_all.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env zsh +buildconfigs=$( oc get buildconfigs -l gitpoller.unstable.tech/type=basic -o json ) + +jq ".items[]" -c <<< $buildconfigs | while read -r line; do; + # jq <<< $line + name=$(jq -r ".metadata.name" <<< $line) + gituri=$(jq -r ".spec.source.git.uri" <<< $line) + gitref=$(jq -r ".spec.source.git.ref // \"main\"" <<< $line) + echo "$name = $gituri:$gitref" + ref=$(git ls-remote -h "$gituri" "refs/heads/$gitref" | cut -f1) + checkref=$(jq -r ".metadata.annotations.\"gitpoller.unstable.tech/lastref\"" <<< $line) + if [[ "$ref" != "$checkref" ]]; then + echo "Update needed for $name" + oc start-build "$name" -w && oc annotate --overwrite buildconfig "$name" "gitpoller.unstable.tech/lastref=$ref" + else + echo "$name is up to date" + fi +done + +echo done