Skip to content

Commit

Permalink
Adding action for deleting image (#209)
Browse files Browse the repository at this point in the history
* Adding action for deleting image

* Only trigger when deleting
  • Loading branch information
gvegayon authored Dec 11, 2024
1 parent a2073dc commit 62a4ced
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/delete-container-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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: Login to the Container Registry
uses: docker/login-action@v3
with:
registry: "cfaprdbatchcr.azurecr.io"
username: "cfaprdbatchcr"
password: ${{ secrets.CFAPRDBATCHCR_REGISTRY_PASSWORD }}

- name: Deleting the image
run: |
az acr repository delete \
--name ${{ env.REGISTRY }} \
--image ${{ env.IMAGE_NAME }}:${{ steps.branch-name.outputs.branch}}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ and [code of conduct](https://github.com/CDCgov/template/blob/master/code-of-con

Describe the purpose of your project. Add additional sections as necessary to help collaborators and potential collaborators understand and use your project.

## Containers

The project uses GitHub Actions for automatically building container images based on the project's [Containerfile](Containerfile) and [Containerfile.dependencies](Containerfile.dependencies) files. The images are currently hosted on Azure Container Registry and are built and pushed via the [containers.yaml](.github/workflows/containers.yaml) GitHub Actions workflow.

Container images pushed to the Azure Container Registry are automatically tagged as either `latest` (if the commit is on the `main` branch) or with the branch name (if the commit is on a different branch). After a branch is deleted, the image tag is remove from the registry via the [delete-container-tag.yaml](.github/workflows/delete-container-tag.yaml) GitHub Actions workflow.

## Project Admin

Name, Degrees, e-mail, CDC org (e.g., CDC/IOD/ORR/CFA)
Expand Down

0 comments on commit 62a4ced

Please sign in to comment.