Skip to content

Commit

Permalink
chore(ci): add retention policy for container registry
Browse files Browse the repository at this point in the history
Automatically delete Docker containers from ghcr.io registry.
All untagged container versions older than 2 weeks and also
partially corrupted multi-platform images will be deleted.

Special action from community:

- dataaxiom/ghcr-cleanup-action@v1 (v1.0.13)

Signed-off-by: Stephan Linz <[email protected]>
  • Loading branch information
rexut committed Oct 11, 2024
1 parent 930adb4 commit 95937d1
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/retention-policy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Retention Policy

on:
workflow_dispatch: # And manually on button click
schedule:
# every day at 00:05 UTC
- cron: '5 0 * * *'

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
clean:
name: Clean up the registry

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
# Delete all untagged Docker images older than 2 weeks.
# https://github.com/dataaxiom/ghcr-cleanup-action
- name: Delete untagged Docker images on registry ${{ env.REGISTRY }}
uses: dataaxiom/ghcr-cleanup-action@v1
with:
older-than: 2 weeks
delete-untagged: true
delete-partial-images: true
exclude-tags: "^\\d+\\.\\d+\\.\\d+$|^latest$|^main$|^nightly$"
use-regex: true
packages: ${{ github.event.repository.name }}
owner: ${{ github.repository_owner }}
token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 95937d1

Please sign in to comment.