Files

110 lines
3.3 KiB
YAML
Raw Permalink Normal View History

2025-11-08 23:29:25 +00:00
name: Cleanup Registry Images
on:
schedule:
2025-11-08 23:53:00 +00:00
# Run daily at 01:30 UTC
- cron: '30 1 * * *'
2025-11-08 23:29:25 +00:00
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run (check only, no actual deletion)'
required: false
2025-11-08 23:53:00 +00:00
default: false
2025-11-08 23:29:25 +00:00
type: boolean
2025-11-08 23:53:00 +00:00
pull_request:
types: [closed]
delete:
# Triggered when branches are deleted
2025-11-08 23:29:25 +00:00
concurrency:
group: "cleanup-registry"
cancel-in-progress: false
env:
BUILTIN_REGISTRY: forgejo.ellis.link
IMAGE_PATH: forgejo.ellis.link/continuwuation/continuwuity
jobs:
2025-11-08 23:53:00 +00:00
cleanup-pr-images:
name: Cleanup PR Images
2025-11-08 23:29:25 +00:00
runs-on: ubuntu-latest
2025-11-08 23:53:00 +00:00
if: github.event_name == 'pull_request' && github.event.action == 'closed'
permissions:
packages: write
2025-11-08 23:29:25 +00:00
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
persist-credentials: false
2025-11-08 23:53:00 +00:00
- 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
2025-11-08 23:29:25 +00:00
id: params
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "dry_run=${{ inputs.dry_run }}" >> $GITHUB_OUTPUT
else
2025-11-08 23:53:00 +00:00
# Scheduled runs perform actual cleanup
2025-11-08 23:29:25 +00:00
echo "dry_run=false" >> $GITHUB_OUTPUT
fi
2025-11-08 23:53:00 +00:00
- name: Cleanup old SHA commit images
uses: https://github.com/dataaxiom/ghcr-cleanup-action@v1
2025-11-08 23:29:25 +00:00
with:
2025-11-08 23:53:00 +00:00
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
2025-11-08 23:29:25 +00:00
2025-11-08 23:53:00 +00:00
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
2025-11-08 23:29:25 +00:00
with:
2025-11-08 23:53:00 +00:00
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