From 75731cb1b0d32b5ec5554e7b251b5257eb642c50 Mon Sep 17 00:00:00 2001 From: "Aman Kumar [SSW]" <71385247+amankumarrr@users.noreply.github.com> Date: Thu, 21 Mar 2024 12:12:49 +1100 Subject: [PATCH] Pipeline - Adding a step to clean up untagged images (#2342) * Pipeline - Adding a step to clean up untagged images Fixed: #2337 * Fixing it to suggested format --- .github/workflows/pr-close-delete-env.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/pr-close-delete-env.yml b/.github/workflows/pr-close-delete-env.yml index 406ccc404..047f79ca8 100644 --- a/.github/workflows/pr-close-delete-env.yml +++ b/.github/workflows/pr-close-delete-env.yml @@ -114,6 +114,21 @@ jobs: Write-Host '❌ Key Vault not found' } + - name: Delete all untagged images + run: | + az acr manifest list-metadata ` + -r ${{ env.ACR_NAME }} ` + -n ${{ env.IMAGE_NAME }} ` + --query "[?tags==null].digest" ` + -o tsv | ` + %{ ` + az acr repository delete ` + -n ${{ env.ACR_NAME }} ` + -t ${{ env.IMAGE_NAME }}@$_ ` + --yes ` + } + Write-Host "✅ All untagged images have been deleted" + - name: ACR - Delete image run: | $imageTagWithPrefix = '${{ env.SLOT_PREFIX }}${{ matrix.SLOT_NAME}}'