110 lines
3.3 KiB
YAML
110 lines
3.3 KiB
YAML
name: Cleanup Registry Images
|
|
|
|
on:
|
|
schedule:
|
|
# Run daily at 01:30 UTC
|
|
- cron: '30 1 * * *'
|
|
workflow_dispatch:
|
|
inputs:
|
|
dry_run:
|
|
description: 'Dry run (check only, no actual deletion)'
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
pull_request:
|
|
types: [closed]
|
|
delete:
|
|
# Triggered when branches are deleted
|
|
|
|
concurrency:
|
|
group: "cleanup-registry"
|
|
cancel-in-progress: false
|
|
|
|
env:
|
|
BUILTIN_REGISTRY: forgejo.ellis.link
|
|
IMAGE_PATH: forgejo.ellis.link/continuwuation/continuwuity
|
|
|
|
jobs:
|
|
cleanup-pr-images:
|
|
name: Cleanup PR Images
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'pull_request' && github.event.action == 'closed'
|
|
permissions:
|
|
packages: write
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v5
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Delete PR image
|
|
uses: https://github.com/dataaxiom/ghcr-cleanup-action@v1
|
|
with:
|
|
token: ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
|
|
owner: continuwuation
|
|
repository: continuwuity
|
|
package: continuwuity
|
|
registry-url: https://${{ env.BUILTIN_REGISTRY }}
|
|
delete-tags: pr-${{ github.event.pull_request.number }}
|
|
dry-run: false
|
|
|
|
cleanup-old-commits:
|
|
name: Cleanup Old Commit Images
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
|
|
permissions:
|
|
packages: write
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v5
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Set dry-run mode
|
|
id: params
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
echo "dry_run=${{ inputs.dry_run }}" >> $GITHUB_OUTPUT
|
|
else
|
|
# Scheduled runs perform actual cleanup
|
|
echo "dry_run=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Cleanup old SHA commit images
|
|
uses: https://github.com/dataaxiom/ghcr-cleanup-action@v1
|
|
with:
|
|
token: ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
|
|
owner: continuwuation
|
|
repository: continuwuity
|
|
package: continuwuity
|
|
registry-url: https://${{ env.BUILTIN_REGISTRY }}
|
|
delete-tags: sha-*
|
|
exclude-tags: latest,main,v*.*.*,*.*.*,*-maxperf
|
|
older-than: 30 days
|
|
dry-run: ${{ steps.params.outputs.dry_run }}
|
|
delete-ghost-images: true
|
|
delete-partial-images: true
|
|
delete-orphaned-images: true
|
|
|
|
cleanup-branch-images:
|
|
name: Cleanup Deleted Branch Images
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'delete' && github.event.ref_type == 'branch'
|
|
permissions:
|
|
packages: write
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v5
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Delete branch image
|
|
uses: https://github.com/dataaxiom/ghcr-cleanup-action@v1
|
|
with:
|
|
token: ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
|
|
owner: continuwuation
|
|
repository: continuwuity
|
|
package: continuwuity
|
|
registry-url: https://${{ env.BUILTIN_REGISTRY }}
|
|
delete-tags: branch-${{ github.event.ref }}
|
|
dry-run: false
|