Skip to content

Delete tag from container registry #21

Delete tag from container registry

Delete tag from container registry #21

name: Delete tag from container registry
on:
delete:
env:
REGISTRY: cfaprdbatchcr.azurecr.io
IMAGE_NAME: pyrenew-hew
jobs:
delete-container:
if: github.event.ref_type == 'branch'
runs-on: cfa-cdcgov
name: Deleting the container
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 the Container Registry
uses: docker/login-action@v3
with:
registry: "cfaprdbatchcr.azurecr.io"
username: "cfaprdbatchcr"
password: ${{ secrets.CFAPRDBATCHCR_REGISTRY_PASSWORD }}
- name: Login to Azure with NNH Service Principal
id: azure_login_2
uses: azure/login@v2
with:
# managed by EDAV. Contact Amit Mantri or Jon Kislin if you
# have issues. Also, this is documented in the Predict
# handbook.
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 }}