File tree 2 files changed +13
-3
lines changed 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
+ check_if_tags_exists () {
4
+ local image=$1
5
+ local tag=$2
6
+ skopeo list-tags " docker://$image " | jq -r " .Tags | contains([\" $tag \" ])"
7
+ }
8
+
3
9
get_image_label () {
4
10
local label=$1
5
11
local image=$2
Original file line number Diff line number Diff line change 139
139
140
140
# Check if we have everything needed for the build
141
141
source ./build-functions/check-commands.sh
142
-
142
+ # Load all build functions
143
+ source ./build-functions/get-public-image-config.sh
143
144
source ./build-functions/gh-functions.sh
144
145
145
146
IMAGE_NAMES=" ${IMAGE_NAMES-docker.io/ netboxcommunity/ netbox} "
@@ -309,19 +310,22 @@ gh_env "FINAL_DOCKER_TAG=${IMAGE_NAME_TAGS[0]}"
309
310
# ##
310
311
# Checking if the build is necessary,
311
312
# meaning build only if one of those values changed:
313
+ # - a new tag is beeing created
312
314
# - base image digest
313
315
# - netbox git ref (Label: netbox.git-ref)
314
316
# - netbox-docker git ref (Label: org.opencontainers.image.revision)
315
317
# ##
316
- # Load information from registry (only for docker.io )
318
+ # Load information from registry (only for first registry in "IMAGE_NAMES" )
317
319
SHOULD_BUILD=" false"
318
320
BUILD_REASON=" "
319
321
if [ -z " ${GH_ACTION} " ]; then
320
322
# Asuming non Github builds should always proceed
321
323
SHOULD_BUILD=" true"
322
324
BUILD_REASON=" ${BUILD_REASON} interactive"
325
+ elif [ " false" == " $( check_if_tags_exists " ${IMAGE_NAMES[0]} " " $TARGET_DOCKER_TAG " ) " ]; then
326
+ SHOULD_BUILD=" true"
327
+ BUILD_REASON=" ${BUILD_REASON} newtag"
323
328
else
324
- source ./build-functions/get-public-image-config.sh
325
329
echo " Checking labels for '${FINAL_DOCKER_TAG} '"
326
330
BASE_LAST_LAYER=$( get_image_last_layer " ${DOCKER_FROM} " )
327
331
OLD_BASE_LAST_LAYER=$( get_image_label netbox.last-base-image-layer " ${FINAL_DOCKER_TAG} " )
You can’t perform that action at this time.
0 commit comments