ci: establish workflow to clean up image artifacts #1
Workflow file for this run
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
| name: Cleanup GHCR CI Images | |
| on: | |
| pull_request: | |
| branches: [main] | |
| 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: | |
| dry-run-pr: | |
| name: Dry run stale GHCR CI image cleanup | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: read | |
| env: | |
| DRY_RUN: "true" | |
| STALE_HOURS: "24" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| persist-credentials: false | |
| - name: Dry run stale package version deletion | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: bash .github/scripts/cleanup-ghcr-ci-images.sh | |
| cleanup: | |
| name: Delete stale GHCR CI image versions | |
| if: github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| DRY_RUN: ${{ inputs.dry_run || 'false' }} | |
| STALE_HOURS: ${{ inputs.stale_hours || '24' }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| persist-credentials: false | |
| - name: Delete stale package versions | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: bash .github/scripts/cleanup-ghcr-ci-images.sh |