From 05f17ca569b1a02de38d4ffc510a5f462508085d Mon Sep 17 00:00:00 2001 From: Dan Crosby Date: Tue, 2 Jun 2026 12:36:59 -0700 Subject: [PATCH] Fix registry cleanup workflow (#6861) --- .github/workflows/registry_cleanup.yml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/registry_cleanup.yml b/.github/workflows/registry_cleanup.yml index f4f7089c1b..7a2aa037a6 100644 --- a/.github/workflows/registry_cleanup.yml +++ b/.github/workflows/registry_cleanup.yml @@ -39,9 +39,9 @@ jobs: echo "Dry run: ${DRY_RUN}" echo "" - # List of repositories to clean - # Use tail to skip header row in case --no-header doesn't work - REPOS=$(doctl registry repository list-v2 --format Name --no-header | grep -v '^Name$' | grep -v '^$') + # List repositories via JSON. Text output can wrap table rows and make + # headers/tags/digests look like repository names. + REPOS=$(doctl registry repository list-v2 "${REGISTRY}" --output json | jq -r '.[] | .name // .Name // empty') for REPO in $REPOS; do echo "=== Processing repository: ${REPO} ===" @@ -88,5 +88,20 @@ jobs: if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'false') run: | echo "Starting garbage collection..." - doctl registry garbage-collection start --force - echo "Garbage collection started. It may take a few minutes to complete." + set +e + GC_OUTPUT=$(doctl registry garbage-collection start --force 2>&1) + GC_STATUS=$? + set -e + + echo "$GC_OUTPUT" + if [ "$GC_STATUS" -eq 0 ]; then + echo "Garbage collection started. It may take a few minutes to complete." + exit 0 + fi + + if echo "$GC_OUTPUT" | grep -q "automated garbage collection is enabled"; then + echo "Automated garbage collection is enabled for this registry; skipping manual garbage collection." + exit 0 + fi + + exit "$GC_STATUS"