From 7f03a37e1635652f7ab14177fc77a9668f11aea4 Mon Sep 17 00:00:00 2001 From: Alexander Stehlik Date: Wed, 17 Jul 2024 01:42:14 +0200 Subject: [PATCH] [PIMINT-171] Improve cleanup Also remove tagged images older than 2 hours to cleanup signatures. --- .github/workflows/docker-registry-cleanup.yaml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-registry-cleanup.yaml b/.github/workflows/docker-registry-cleanup.yaml index d7c1554..8f70734 100644 --- a/.github/workflows/docker-registry-cleanup.yaml +++ b/.github/workflows/docker-registry-cleanup.yaml @@ -38,27 +38,21 @@ jobs: id: multi-arch-digests working-directory: /tmp/build-metadata/image-tags run: | - digests="" imageNames="" for identifier in *; do imageNameAndTag="$(cat ${identifier})" imageName=$(echo $imageNameAndTag | cut -d: -f1) - imageUrl="${{ inputs.image_registry }}/${{ github.repository_owner }}/${imageNameAndTag}" - imageDigests=$(docker manifest inspect ${imageUrl} | jq -r '.manifests[] | .digest' | paste -s -d ' ' -) imageNames="$imageNames $imageName" - digests="$digests $imageDigests" done - echo "multi-arch-digests=$digests" >> $GITHUB_OUTPUT - echo "image-names=$imageNames" >> $GITHUB_OUTPUT + unqiueImageNames=$(echo $imageNames | tr ' ' '\n' | sort -u | tr '\n' ' ') + echo "image-names=$unqiueImageNames" >> $GITHUB_OUTPUT - uses: snok/container-retention-policy@v3.0.0 with: account: basecom token: ${{ secrets.GITHUB_TOKEN }} image-names: ${{ steps.multi-arch-digests.outputs.image-names }} - cut-off: 0s - tag-selection: untagged + cut-off: 2h dry-run: false - skip-shas: ${{ steps.multi-arch-digests.outputs.multi-arch-digests }}