Cleanup GHCR Packages #69
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |
| # SPDX-License-Identifier: Apache-2.0 | |
| name: Cleanup GHCR Packages | |
| on: | |
| schedule: | |
| - cron: "43 4 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| dry-run: | |
| description: Log stale GHCR package versions without deleting them. | |
| required: false | |
| type: boolean | |
| default: false | |
| stale-hours: | |
| description: Delete versions last updated more than this many hours ago. | |
| required: false | |
| type: number | |
| default: 24 | |
| permissions: {} | |
| concurrency: | |
| group: ghcr-cleanup-${{ github.repository }} | |
| cancel-in-progress: false | |
| jobs: | |
| cleanup-ci: | |
| name: Delete stale GHCR CI image versions | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| DRY_RUN: ${{ inputs['dry-run'] || 'false' }} | |
| STALE_HOURS: ${{ inputs['stale-hours'] || '24' }} | |
| CLEANUP_SCOPE: ci | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| persist-credentials: false | |
| - name: Log in to GHCR | |
| uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Delete stale package versions | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: bash .github/scripts/cleanup-ghcr-ci-images.sh | |
| cleanup-nightly-releases: | |
| name: Delete GHCR nightly release versions older than 90 days | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| DRY_RUN: ${{ inputs['dry-run'] || 'false' }} | |
| STALE_HOURS: "2160" | |
| CLEANUP_SCOPE: nightly-release | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| persist-credentials: false | |
| - name: Log in to GHCR | |
| uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Delete stale nightly release versions | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: bash .github/scripts/cleanup-ghcr-ci-images.sh |