diff --git a/.github/workflows/clean_tags.sh b/.github/workflows/clean_tags.sh index 3d8c34e0..7736bc7d 100755 --- a/.github/workflows/clean_tags.sh +++ b/.github/workflows/clean_tags.sh @@ -57,9 +57,9 @@ do echo "Checking image $image_name..." escaped_image_name=$(echo ${image_name} | sed "s/\//%2f/g") response=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/orgs/devcontainers/packages/container/$escaped_image_name/versions") - message=$(echo $response | jq -r .message) - if [[ $message == "null" ]]; then - version_id=$( | jq -r ".[] | select(.metadata.container.tags | index(\"${tag}\")) | .id") + message=$(echo "$response" | jq -r ".message?") + if [[ -z "$message" || "$message" == "null" ]]; then + version_id=$(echo "$response" | jq -r ".[] | select(.metadata.container.tags | index(\"${tag}\")) | .id") if [[ -n $version_id ]]; then echo "Found version '$version_id' for '$image_name:$tag' - deleting..." curl -s -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/orgs/devcontainers/packages/container/$escaped_image_name/versions/$version_id" diff --git a/.github/workflows/clean_untagged.sh b/.github/workflows/clean_untagged.sh index 205ebe2d..87e77dfb 100755 --- a/.github/workflows/clean_untagged.sh +++ b/.github/workflows/clean_untagged.sh @@ -18,9 +18,9 @@ do echo "Checking for untagged versions for $image_name" escaped_image_name=$(echo ${image_name} | sed "s/\//%2f/g") response=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/orgs/devcontainers/packages/container/$escaped_image_name/versions?per_page=100") - message=$(echo $response | jq -r ".message?") + message=$(echo "$response" | jq -r ".message?") if [[ -z "$message" || "$message" == "null" ]]; then - version_ids=$( | jq -r ".[] | select(.metadata.container.tags | length ==0) | .id") + version_ids=$(echo "$response" | jq -r ".[] | select(.metadata.container.tags | length ==0) | .id") for version_id in ${version_ids[@]}; do echo -e "\tDeleting version '$version_id' for '$image_name:$tag' ..."