Compare commits
1 commit
main
...
jade/clean
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5927380f9 |
1 changed files with 72 additions and 33 deletions
|
|
@ -2,25 +2,19 @@ name: Cleanup Registry Images
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
# Run daily at midnight UTC
|
# Run daily at 01:30 UTC
|
||||||
- cron: '0 0 * * *'
|
- cron: '30 1 * * *'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
dry_run:
|
dry_run:
|
||||||
description: 'Dry run (check only, no actual deletion)'
|
description: 'Dry run (check only, no actual deletion)'
|
||||||
required: false
|
required: false
|
||||||
default: true
|
default: false
|
||||||
type: boolean
|
type: boolean
|
||||||
grace_period:
|
pull_request:
|
||||||
description: 'Grace period (e.g., 24h, 48h, 168h)'
|
types: [closed]
|
||||||
required: false
|
delete:
|
||||||
default: '24h'
|
# Triggered when branches are deleted
|
||||||
type: string
|
|
||||||
keep_count:
|
|
||||||
description: 'Number of images to keep per tag pattern'
|
|
||||||
required: false
|
|
||||||
default: '30'
|
|
||||||
type: string
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: "cleanup-registry"
|
group: "cleanup-registry"
|
||||||
|
|
@ -31,41 +25,86 @@ env:
|
||||||
IMAGE_PATH: forgejo.ellis.link/continuwuation/continuwuity
|
IMAGE_PATH: forgejo.ellis.link/continuwuation/continuwuity
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
cleanup-registry:
|
cleanup-pr-images:
|
||||||
|
name: Cleanup PR Images
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'pull_request' && github.event.action == 'closed'
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Set cleanup parameters
|
- 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
|
id: params
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
echo "dry_run=${{ inputs.dry_run }}" >> $GITHUB_OUTPUT
|
echo "dry_run=${{ inputs.dry_run }}" >> $GITHUB_OUTPUT
|
||||||
echo "grace_period=${{ inputs.grace_period }}" >> $GITHUB_OUTPUT
|
|
||||||
echo "keep_count=${{ inputs.keep_count }}" >> $GITHUB_OUTPUT
|
|
||||||
else
|
else
|
||||||
# Scheduled runs are not dry-run by default
|
# Scheduled runs perform actual cleanup
|
||||||
echo "dry_run=false" >> $GITHUB_OUTPUT
|
echo "dry_run=false" >> $GITHUB_OUTPUT
|
||||||
echo "grace_period=24h" >> $GITHUB_OUTPUT
|
|
||||||
echo "keep_count=30" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Login to registry
|
- name: Cleanup old SHA commit images
|
||||||
uses: docker/login-action@v3
|
uses: https://github.com/dataaxiom/ghcr-cleanup-action@v1
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.BUILTIN_REGISTRY }}
|
token: ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
|
||||||
username: ${{ vars.BUILTIN_REGISTRY_USER || github.actor }}
|
owner: continuwuation
|
||||||
password: ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
|
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
|
||||||
|
|
||||||
- name: Clean up old SHA commit images
|
cleanup-branch-images:
|
||||||
uses: docker://us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli
|
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:
|
with:
|
||||||
args: >-
|
persist-credentials: false
|
||||||
-repo=${{ env.IMAGE_PATH }}
|
|
||||||
-tag-filter-all="sha-[0-9a-f]+"
|
- name: Delete branch image
|
||||||
-keep=${{ steps.params.outputs.keep_count }}
|
uses: https://github.com/dataaxiom/ghcr-cleanup-action@v1
|
||||||
-grace=${{ steps.params.outputs.grace_period }}
|
with:
|
||||||
${{ steps.params.outputs.dry_run == 'true' && '-dry-run' || '' }}
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue