From 54ca044bdbd8942629378d7a6fa85e45cd4b9d36 Mon Sep 17 00:00:00 2001 From: Thuan Vo Date: Thu, 11 Jul 2024 06:36:21 -0700 Subject: [PATCH] ci(build): query scorecard image tags with registry v2 api (#915) Signed-off-by: Thuan Vo --- .github/workflows/build-ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-ci.yml b/.github/workflows/build-ci.yml index c5c06682..b16417c9 100644 --- a/.github/workflows/build-ci.yml +++ b/.github/workflows/build-ci.yml @@ -107,9 +107,14 @@ jobs: id: check-tag-exists run: | EXIST=false - if [ -n "$(podman search --list-tags ${CI_SCORECARD_IMG} --format json | jq --arg TAG ${{ steps.get-image-tag.outputs.tag }} '.[0].Tags[] | select( . == $TAG)')" ]; then + STATUS_CODE=$(curl -ILs -o /dev/null https://quay.io/v2/${CI_SCORECARD_IMG/"quay.io/"/}/manifests/${{ steps.get-image-tag.outputs.tag }} -w "%{http_code}") + if [ ${STATUS_CODE} -eq 200 ]; then EXIST=true + elif [ ${STATUS_CODE} -ne 404 ]; then + echo "Failed to query image's existence with status code ${STATUS_CODE}" + exit 1 fi + echo "${CI_SCORECARD_IMG}:${{ steps.get-image-tag.outputs.tag }} exists: $EXIST" echo "exist=$EXIST" >> $GITHUB_OUTPUT - name: Install podman v4 run: |