Skip to content

Commit fc1398e

Browse files
authored
Apply labels from addon build.json (#203)
1 parent 08b0f4a commit fc1398e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

builder.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ function build_addon() {
516516
if bashio::fs.file_exists "/tmp/build_config/build.json"; then
517517
build_from="$(jq --raw-output ".build_from.$build_arch // empty" "/tmp/build_config/build.json")"
518518
args="$(jq --raw-output '.args // empty | keys[]' "/tmp/build_config/build.json")"
519+
labels="$(jq --raw-output '.labels // empty | keys[]' "/tmp/build_config/build.json")"
519520
shadow_repository="$(jq --raw-output '.shadow_repository // empty' "/tmp/build_config/build.json")"
520521
fi
521522

@@ -532,13 +533,21 @@ function build_addon() {
532533
done
533534
fi
534535

536+
# Additional build labels
537+
if bashio::var.has_value "${labels}"; then
538+
for label in ${labels}; do
539+
value="$(jq --raw-output ".labels.\"${label}\"" "/tmp/build_config/build.json")"
540+
docker_cli+=("--label" "${label}=${value}")
541+
done
542+
fi
543+
535544
# Read addon config.json
536545
name="$(jq --raw-output '.name // empty' "/tmp/build_config/config.json" | sed "s/'//g")"
537546
description="$(jq --raw-output '.description // empty' "/tmp/build_config/config.json" | sed "s/'//g")"
538547
url="$(jq --raw-output '.url // empty' "/tmp/build_config/config.json")"
539548
raw_image="$(jq --raw-output '.image // empty' "/tmp/build_config/config.json")"
540549
mapfile -t supported_arch < <(jq --raw-output '.arch // empty' "/tmp/build_config/config.json")
541-
550+
542551
# Read version from config.json when VERSION is not set
543552
if [ -n "$VERSION" ]; then
544553
version="$VERSION"
@@ -740,7 +749,7 @@ function cosign_sign() {
740749
if bashio::var.false "${DOCKER_PUSH}" || bashio::var.false "${COSIGN}"; then
741750
return 0
742751
fi
743-
752+
744753
for j in {1..6}; do
745754
if cosign sign --yes "${image}"; then
746755
success=true

0 commit comments

Comments
 (0)