-
Notifications
You must be signed in to change notification settings - Fork 1
58 lines (49 loc) · 1.76 KB
/
delete-container-tag.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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 }}