Skip to content

Commit

Permalink
Fix scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Nov 9, 2023
1 parent ced74db commit c847b2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/clean_tags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/clean_untagged.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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' ..."
Expand Down

0 comments on commit c847b2f

Please sign in to comment.