Skip to content

Cleanup Old Container Versions #22

Cleanup Old Container Versions

Cleanup Old Container Versions #22

name: Cleanup Old Container Versions
# Prunes orphaned/untagged GHCR image versions on a weekly schedule.
#
# Nightly: only the tag `nightly` is published. Each new `main` build moves that
# tag to a new digest; the previous build usually becomes *untagged* and is a
# candidate for removal here, so you do not accumulate a history of nightly
# images. Semver, `latest`, and release `sha-*` always stay tagged and are not
# deleted by this job (only untagged package versions are selected).
#
# This job deletes: untagged package versions, subject to
# `min-versions-to-keep`. It never deletes a version that still has a tag.
#
# To also prune *tagged* old versions, change package settings or a different
# process; this action is untagged-only by design.
on:
schedule:
# Sundays 05:00 UTC
- cron: "0 5 * * 0"
workflow_dispatch:
inputs:
dry-run:
description: "If true, list versions that would be deleted without deleting them."
required: false
default: "false"
type: choice
options: ["false", "true"]
permissions:
contents: read
packages: write
jobs:
prune-untagged:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Prune untagged container versions
uses: ./.github/actions/prune-untagged-ghcr
with:
owner: ${{ github.repository_owner }}
package-name: ${{ github.event.repository.name }}
min-versions-to-keep: "5"
dry-run: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.dry-run || 'false' }}