chore(ci): fix possible empty version meta on image (#750)

This ensures that when inspecting upstream image, if an error occurs, or
the resulting value is empty or 'null', we fail our build instead of
propegating a bogus version downstream.

Relates: https://github.com/ublue-os/main/issues/487
This commit is contained in:
Benjamin Sherman 2024-02-06 22:05:40 -06:00 committed by GitHub
parent 950e7c7c07
commit 29ea11a14b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -183,7 +183,9 @@ jobs:
- name: Get Current Fedora Version
id: labels
shell: bash
run: |
set -eo pipefail
if [[ "${{ matrix.base_name }}" == "bazzite-nvidia" ]]; then
ver=$(skopeo inspect docker://ghcr.io/ublue-os/bazzite-${{ env.IMAGE_FLAVOR }}:${{ matrix.major_version }} | jq -r '.Labels["org.opencontainers.image.version"]')
elif [[ "${{ env.IMAGE_FLAVOR}}" == "main" ]]; then
@ -191,6 +193,10 @@ jobs:
else
ver=$(skopeo inspect docker://ghcr.io/ublue-os/${{ matrix.base_image_name }}-${{ env.IMAGE_FLAVOR }}:${{ matrix.major_version }} | jq -r '.Labels["org.opencontainers.image.version"]')
fi
if [ -z "$ver" ] || [ "null" = "$ver" ]; then
echo "inspected image version must not be empty or null"
exit 1
fi
echo "VERSION=$ver" >> $GITHUB_OUTPUT
# Build metadata