Skip to content

Cleanup Old Packages #1

Cleanup Old Packages

Cleanup Old Packages #1

# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Netresearch DTT GmbH
#
# Weekly GHCR retention for the glpi-php-fpm package.
#
# The daily build.yml pushes a fresh multi-arch image; each push leaves the
# previous build's per-arch child manifests UNTAGGED behind the moving tags
# (latest / 11 / 11.0 / dated). Left unchecked these untagged versions
# accumulate forever. This job prunes them while keeping a safety margin, and
# NEVER touches tagged versions (no released image is ever deleted here).
name: Cleanup Old Packages
on:
workflow_dispatch:
schedule:
# Weekly, Sundays 03:00 UTC.
- cron: '0 3 * * 0'
# Deny by default; the single job opts into packages:write only.
permissions: {}
env:
PACKAGE_NAME: glpi-php-fpm
jobs:
cleanup:
name: prune untagged versions
runs-on: ubuntu-latest
permissions:
packages: write
steps:
# Manifest-list + referrer aware: actions/delete-package-versions is NOT,
# so it would happily delete a per-arch CHILD manifest (or a cosign sig /
# SLSA attestation referrer) of a LIVE tagged index once enough newer
# untagged versions exist — silently breaking multi-arch pulls and
# verification (the same failure mode that bricked ghcr's phpbu-docker).
# dataaxiom/ghcr-cleanup-action understands manifest lists: it keeps the
# children + referrers of every tagged image and only removes orphans.
- name: Delete orphaned / partial versions (manifest-aware)
uses: dataaxiom/ghcr-cleanup-action@d52806a0dc70b430571a37da1fde39733ffd640f # v1.2.2
with:
packages: ${{ env.PACKAGE_NAME }}
delete-untagged: true # orphaned untagged manifests
delete-partial-images: true # incomplete multi-arch pushes
delete-ghost-images: true # tags whose children were GC'd
keep-n-untagged: 10 # rollback margin
# Children + cosign/SLSA referrers of TAGGED images are retained
# automatically — tagged releases are never broken.
- name: Summary
env:
PACKAGE_NAME: ${{ env.PACKAGE_NAME }}
run: |
{
echo "## Package Cleanup Summary"
echo ""
echo "- Package: \`${PACKAGE_NAME}\` (container)"
echo "- Kept minimum: 10 untagged versions"
echo "- Manifest-aware prune (children + sig/attestation referrers of tagged images kept)"
} >> "$GITHUB_STEP_SUMMARY"