From 662a61a413151f11129e6b579c7b42828be500ab Mon Sep 17 00:00:00 2001 From: Radoslav Dimitrov Date: Thu, 20 Sep 2018 23:10:48 +0000 Subject: [PATCH] Check if the Docker image is already present. Proceed with building the image only if it's not already available. Signed-off-by: Radoslav Dimitrov --- contrib/publish-armhf.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) mode change 100644 => 100755 contrib/publish-armhf.sh diff --git a/contrib/publish-armhf.sh b/contrib/publish-armhf.sh old mode 100644 new mode 100755 index 49aa4db7..6a78f9ab --- a/contrib/publish-armhf.sh +++ b/contrib/publish-armhf.sh @@ -11,17 +11,35 @@ HERE=`pwd` #fi +get_repo_name() { + if [ "openfaas-incubator/faas-idler" = $1 ]; then + echo "openfaas/faas-idler" + elif [ "openfaas/faas" = $1 ]; then + echo "openfaas/gateway" + elif [ "openfaas/nats-queue-worker" = $1 ]; then + echo "openfaas/queue-worker" + else + echo $1 + fi +} + for i in "${repos[@]}" do cd $HERE - echo "$i" + echo -e "\nBuilding: $i\n" git clone https://github.com/$i ./staging/$i cd ./staging/$i pwd export TAG=$(git describe --abbrev=0 --tags) echo "Latest release: $TAG" - make ci-armhf-build ci-armhf-push + REPOSITORY=$(get_repo_name $i) + TAG_PRESENT=$(curl -s "https://hub.docker.com/v2/repositories/${REPOSITORY}/tags/${TAG}-armhf/" | jq -r ".detail") + if [ "$TAG_PRESENT" = "Not found" ]; then + make ci-armhf-build ci-armhf-push + else + echo "Image is already present: ${REPOSITORY}:${TAG}-armhf" + fi done