File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -36,15 +36,19 @@ jobs:
3636 /orgs/${{ env.ORG }}/packages/container/${{ env.IMAGE_NAME }}/versions \
3737 --paginate | jq -r '.[] | select(.metadata.container.tags[] | startswith("${{ env.TAG_PREFIX }}")) | "\(.id) \(.metadata.container.tags[])"' | grep '^.* ${{ env.TAG_PREFIX }}' | sort -k2 -r)
3838
39- # Get the IDs to delete (skip the first ${{ env.KEEP_X_IMAGES }} versions)
40- IDS_TO_DELETE =$(echo "$VERSIONS" | awk '{print $1}' | sed "1,${{ env.KEEP_X_IMAGES }}d" | sort -u )
39+ # Get the lines to delete (skip the first ${{ env.KEEP_X_IMAGES }} versions)
40+ TO_DELETE =$(echo "$VERSIONS" | sed "1,${{ env.KEEP_X_IMAGES }}d")
4141
42- echo "Version IDs to delete: $IDS_TO_DELETE"
43- for id in $IDS_TO_DELETE; do
44- echo "Deleting version ID $id"
42+ echo "Deleting the following tags:"
43+ echo "$TO_DELETE" | awk '{print $2}'
44+
45+ while read -r line; do
46+ id=$(echo "$line" | awk '{print $1}')
47+ tag=$(echo "$line" | awk '{print $2}')
48+ echo "Deleting tag $tag (version ID $id)"
4549 gh api -X DELETE -H "Accept: application/vnd.github+json" \
46- /orgs/${{ env.ORG }}/packages/container/${{ env.IMAGE_NAME }}/versions/$id || echo "Failed to delete version $id"
47- done
50+ /orgs/${{ env.ORG }}/packages/container/${{ env.IMAGE_NAME }}/versions/$id || echo "Failed to delete version $id ($tag) "
51+ done <<< "$TO_DELETE"
4852
4953 - name : List remaining ${{ env.TAG_PREFIX }}* tags and their version IDs (debug)
5054 run : |
You can’t perform that action at this time.
0 commit comments