Skip to content

Delete branch tag from container registry #76

Delete branch tag from container registry

Delete branch tag from container registry #76

name: Delete branch tag from container registry
on:
delete:
env:
REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
IMAGE_NAME: pyrenew-hew
jobs:
delete-container:
if: github.event.ref_type == 'branch'
runs-on: cfa-cdcgov
name: Delete tag
steps:
- name : Checkout code
uses: actions/checkout@v4
- name: Figure out tag (either latest if it is main or the branch name)
id: image-tag
run: |
if [ "${{ github.event.ref }}" = "main" ]; then
echo "The image associated with the main branch cannot be deleted."
exit 1
else
echo "tag=${{ github.event.ref }}" >> $GITHUB_OUTPUT
fi
- name: Login to Azure
id: azure_login_2
uses: azure/login@v2
with:
creds: ${{ secrets.EDAV_STF_SERVICE_PRINCIPAL }}
- name: Deleting the image
run: |
# Remove the image from the registry
az acr repository delete \
--yes \
--name ${{ env.REGISTRY }} \
--image ${{ env.IMAGE_NAME }}:${{ steps.image-tag.outputs.tag }}
# Remove the dependencies image from the registry
az acr repository delete \
--yes \
--name ${{ env.REGISTRY }} \
--image ${{ env.IMAGE_NAME }}:dependencies-${{ steps.image-tag.outputs.tag }}