From 83c8e5cf7b56232b250dc1c7896cef2fb5c49aad Mon Sep 17 00:00:00 2001 From: "Aman Kumar [SSW]" <71385247+amankumarrr@users.noreply.github.com> Date: Thu, 21 Mar 2024 11:12:26 +1100 Subject: [PATCH 1/2] Pipeline - Adding a step to clean up untagged images Fixed: #2337 --- .github/workflows/pr-close-delete-env.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/pr-close-delete-env.yml b/.github/workflows/pr-close-delete-env.yml index 406ccc404..ea8fdc5af 100644 --- a/.github/workflows/pr-close-delete-env.yml +++ b/.github/workflows/pr-close-delete-env.yml @@ -114,6 +114,13 @@ jobs: Write-Host '❌ Key Vault not found' } + - name: Delete all untagged images + run: | + $untaggedDigests = 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}}' From 4bdd8c588cdef9c26db760a0b9fc06905ad0cba7 Mon Sep 17 00:00:00 2001 From: "Aman Kumar [SSW]" <71385247+amankumarrr@users.noreply.github.com> Date: Thu, 21 Mar 2024 11:57:30 +1100 Subject: [PATCH 2/2] Fixing it to suggested format --- .github/workflows/pr-close-delete-env.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-close-delete-env.yml b/.github/workflows/pr-close-delete-env.yml index ea8fdc5af..047f79ca8 100644 --- a/.github/workflows/pr-close-delete-env.yml +++ b/.github/workflows/pr-close-delete-env.yml @@ -116,9 +116,17 @@ jobs: - name: Delete all untagged images run: | - $untaggedDigests = 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} + 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