Skip to content

Commit e81cf1b

Browse files
authored
Sign the image before upload it (#101)
1 parent 6792942 commit e81cf1b

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

builder.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ function run_build() {
315315
push_images+=("${shadow_repository}/${image}:${version}")
316316
fi
317317

318+
# Singing image
319+
codenotary_sign "${CODENOTARY_OWNER}" "${repository}/${image}:${version}"
320+
318321
# Push images
319322
if bashio::var.true "${DOCKER_PUSH}"; then
320323
for i in "${push_images[@]}"; do
@@ -333,9 +336,6 @@ function run_build() {
333336
done
334337
done
335338
fi
336-
337-
# Singing image
338-
codenotary_sign "${CODENOTARY_OWNER}" "${repository}/${image}:${version}"
339339
}
340340

341341

@@ -694,6 +694,7 @@ function codenotary_sign() {
694694
local trust=$1
695695
local image=$2
696696
local vcn_cli=()
697+
local success=false
697698

698699
if bashio::var.false "${DOCKER_PUSH}" || bashio::var.false "${VCN_NOTARY}"; then
699700
return 0
@@ -705,8 +706,18 @@ function codenotary_sign() {
705706
vcn_cli+=("--org" "${trust}")
706707
fi
707708

708-
if ! vcn authenticate "${vcn_cli[@]}" --silent "docker://${image}"; then
709-
VCN_NOTARIZATION_PASSWORD="${CODENOTARY_PASSWORD}" vcn notarize --public "docker://${image}" || bashio::exit.nok "Failed to sign the image"
709+
for j in {1..10}; do
710+
if ! vcn authenticate "${vcn_cli[@]}" --silent "docker://${image}"; then
711+
VCN_NOTARIZATION_PASSWORD="${CODENOTARY_PASSWORD}" vcn notarize --public "docker://${image}" || true
712+
else
713+
success=true
714+
break
715+
fi
716+
sleep 5
717+
done
718+
719+
if bashio::var.false "${success}"; then
720+
bashio::exit.nok "Failed to sign the image"
710721
fi
711722
bashio::log.info "Signed ${image} with ${trust}"
712723
}

0 commit comments

Comments
 (0)