Skip to content

Commit

Permalink
delete old docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
erosson committed Jun 2, 2024
1 parent 9e1e22a commit cd91421
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ on:
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
# IMAGE_NAME: ${{ github.repository }}
IMAGE_NAME: swarmsim/www.swarmsim.com
IMAGE_LABEL: www.swarmsim.com

jobs:
build-and-push-image:
Expand All @@ -35,7 +34,7 @@ jobs:
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_LABEL }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
Expand All @@ -52,7 +51,7 @@ jobs:
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-name: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_LABEL }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

Expand All @@ -69,6 +68,18 @@ jobs:
env:
TARGET: erosson/infra
REGISTRY: ${{ env.REGISTRY }}
IMAGE_NAME: ${{ env.IMAGE_NAME }}
IMAGE_NAME: ${{ github.repository_owner }}/${{ env.IMAGE_LABEL }}
REPOSITORY: ${{ github.repository }}
GH_TOKEN_INFRA_BUILD_DOCKER_IMAGE: ${{ secrets.GH_TOKEN_INFRA_BUILD_DOCKER_IMAGE }}

- name: Delete old Docker images
uses: snok/container-retention-policy@v2
with:
image-names: ${{ env.IMAGE_LABEL }}
cut-off: 3 days ago UTC
keep-at-least: 5
skip-tags: master, production
account-type: org
org-name: swarmsim
token: ${{ secrets.GITHUB_TOKEN }}
token-type: github-token

0 comments on commit cd91421

Please sign in to comment.