build.sh: More convenient way to push images

Since build.sh now builds more than just two images, individual queries
whether to push each image to a registry may become tedious.  This patch
replaces the queries with a single checklist menu.  After making
a selection, the images get pushed all at once.

In the menu, all images are unchecked by default in order to prevent
accidental uploads.  This, too, may become tedious.  In that case, the
default could be flipped or a new option could be introduced.
This commit is contained in:
Gernot Schulz 2020-08-14 18:22:19 +02:00 committed by Finn Stutzenstein
parent 418480bff5
commit 1c0724341c
No known key found for this signature in database
GPG Key ID: 9042F605C6324654

View File

@ -91,13 +91,22 @@ for i in "${SELECTED_TARGETS[@]}"; do
else else
docker build --tag "$img" --pull "${OPTIONS[@]}" "$loc" docker build --tag "$img" --pull "${OPTIONS[@]}" "$loc"
fi fi
BUILT_IMAGES+=("$img") BUILT_IMAGES+=("$img OFF")
done done
for img in "${BUILT_IMAGES[@]}"; do if hash whiptail > /dev/null 2>&1; then
read -p "Push image '$img' to repository? [y/N] " REPL while read img; do
case "$REPL" in echo "Pushing ${img}."
Y|y|Yes|yes|YES) docker push "$img"
docker push "$img" ;; done < <( whiptail --title "OpenSlides build script" \
esac --checklist "Select images to push to their registry." \
done 25 78 16 --separate-output --noitem --clear \
${BUILT_IMAGES[@]} \
3>&2 2>&1 1>&3 )
else
printf "\nSuccessfully built images:\n\n"
for i in "${BUILT_IMAGES[@]}"; do
read -r img x <<< "$i"
printf " - $img\n"
done
fi