Skip to content

Delete tag from container registry #10

Delete tag from container registry

Delete tag from container registry #10

name: Delete tag from container registry
on:
delete:
env:
REGISTRY: cfaprdbatchcr.azurecr.io
IMAGE_NAME: pyrenew-hew
jobs:
delete-container:
runs-on: cfa-cdcgov
name: Deleting the container
steps:
- name : Checkout code
uses: actions/checkout@v4
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: branch-name
- name: Figure out tag (either latest if it is main or the branch name)
id: image-tag
run: |
if [ "${{ steps.branch-name.outputs.branch }}" = "main" ]; then
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "tag=${{ steps.branch-name.outputs.branch }}" >> $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 STF 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: |
az acr repository delete \
--yes \
--name ${{ env.REGISTRY }} \
--image ${{ env.IMAGE_NAME }}:${{ steps.image-tag.outputs.tag }}