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
1 changed files with 17 additions and 8 deletions

View File

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