Skip to content

Commit 36fba76

Browse files
fix: use jq first() to handle multiple certified images with same tag
1 parent c40b283 commit 36fba76

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

.github/workflows/build_and_certify_operator.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,15 @@ jobs:
177177
RESPONSE=$(curl -sH "X-API-KEY: ${{ secrets.RED_HAT_API_KEY }}" \
178178
"https://catalog.redhat.com/api/containers/v1/projects/certification/id/${PROJECT_ID}/images?page_size=100")
179179
180-
# Find the image with matching tag and certified status
181-
IMAGE_DATA=$(echo "${RESPONSE}" | jq -r --arg VERSION "${VERSION}" \
182-
'.data[] | select(.repositories[].tags[]?.name == $VERSION) | select(.certified == true)')
180+
# Find the first certified image with matching tag
181+
DIGEST=$(echo "${RESPONSE}" | jq -r --arg VERSION "${VERSION}" \
182+
'[.data[] | select(.repositories[].tags[]?.name == $VERSION) | select(.certified == true)] | first | .docker_image_digest // empty')
183183
184-
if [ -n "${IMAGE_DATA}" ]; then
185-
DIGEST=$(echo "${IMAGE_DATA}" | jq -r '.docker_image_digest')
186-
187-
if [ -n "${DIGEST}" ] && [ "${DIGEST}" != "null" ]; then
188-
echo "✅ Certified! Digest: ${DIGEST}"
189-
echo "certified=true" >> $GITHUB_OUTPUT
190-
echo "digest=${DIGEST}" >> $GITHUB_OUTPUT
191-
exit 0
192-
fi
184+
if [ -n "${DIGEST}" ] && [ "${DIGEST}" != "null" ]; then
185+
echo "✅ Certified! Digest: ${DIGEST}"
186+
echo "certified=true" >> $GITHUB_OUTPUT
187+
echo "digest=${DIGEST}" >> $GITHUB_OUTPUT
188+
exit 0
193189
fi
194190
195191
echo "⏳ Attempt ${ATTEMPT}/${MAX_ATTEMPTS}: Image not yet certified, waiting 10 seconds..."

0 commit comments

Comments
 (0)