Delete tag from container registry #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- 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 \ | |
--name ${{ env.REGISTRY }} \ | |
--image ${{ env.IMAGE_NAME }}:${{ steps.image-tag.outputs.tag }} | |