Skip to content

Retention Policy

Retention Policy #12

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:
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 }}