Fix image ID detection for multiple images

This commit is contained in:
Matt Pryor 2024-01-17 10:55:12 +00:00
parent f718b33969
commit 383dbf1cbc

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -ex
set -exo pipefail
#####
# This script uploads an image to OpenStack unless already present
@ -14,8 +14,7 @@ set -ex
GITHUB_OUTPUT="${GITHUB_OUTPUT:-/dev/stdout}"
# Try to find the ID of an existing image with the required name
# NOTE: This command is allowed/expected to fail sometimes
IMAGE_ID="$(openstack image show -f value -c id "$IMAGE_NAME" || true)"
IMAGE_ID="$(openstack image list -f json --name "$IMAGE_NAME" | jq -r '.[0].ID // empty')"
# If there is an existing image, we are done
if [ -n "$IMAGE_ID" ]; then