From 02df3bfe6d2cb33f177119340c8538ba9d1a8fd1 Mon Sep 17 00:00:00 2001 From: Steven Thomas Date: Tue, 26 Jan 2021 11:32:20 -0500 Subject: [PATCH] Skip image pull if possible --- hooks/command | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hooks/command b/hooks/command index c3f1c42..9d5d17f 100644 --- a/hooks/command +++ b/hooks/command @@ -19,9 +19,13 @@ cd "$( dirname "${BASH_SOURCE[0]}" )/.." TAG=$(git describe --tags --exact-match 2> /dev/null || true) if [[ -n "$TAG" ]]; then - echo "Found tag $TAG, pulling from docker hub" IMAGE="$DOCKER_REPO:$TAG" - docker pull "$IMAGE" + if ! docker image inspect "$IMAGE" &> /dev/null; then + echo "Pulling tag $TAG from docker hub" + docker pull "$IMAGE" + else + echo "Tag $TAG already exists locally, skipping pull" + fi else echo "No tag found, building image locally" IMAGE=test-summary:$BUILDKITE_JOB_ID