Skip to content

Cleanup Old Images

Cleanup Old Images #25

Workflow file for this run

name: Cleanup Old Images
on:
schedule:
- cron: "15 0 * * 0"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
jobs:
delete-old-releases:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Delete Old Releases
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release list --repo ${{ github.repository }} --limit 100 --json tagName,createdAt \
| jq -r 'sort_by(.createdAt) | reverse | .[7:] | .[] | select(.createdAt < (now - 14*86400 | todate)) | .tagName' \
| xargs -r -I {} gh release delete {} --repo ${{ github.repository }} --yes --cleanup-tag
delete-older-than-14:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Delete Older Images
uses: dataaxiom/ghcr-cleanup-action@cd0cdb900b5dbf3a6f2cc869f0dbb0b8211f50c4 # v1.0.16
with:
token: ${{ secrets.GITHUB_TOKEN }}
packages: distinctionos
older-than: 14 days
delete-orphaned-images: true
keep-n-tagged: 7
keep-n-untagged: 7