Skip to content

Commit

Permalink
add dry-run to cleanup + don't fail on error
Browse files Browse the repository at this point in the history
  • Loading branch information
Murazaki committed Jan 19, 2025
1 parent 2c7d753 commit 9de3d84
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/docker-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Docker Cleanup

on:
workflow_dispatch:
inputs:
dry-run:
required: true
type: boolean

# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
schedule:
Expand All @@ -16,30 +20,38 @@ on:
- cron: "30 3 * * 1" # run at 03:30 AM UTC on mondays

jobs:

clean_registry:
name: Clean the container registry
runs-on: ubuntu-latest

steps:
# See: https://github.com/dataaxiom/ghcr-cleanup-action?tab=readme-ov-file#action-options
- name: Delete old PR + Branch images
- if: always()
name: Delete old PR + Branch images
uses: dataaxiom/ghcr-cleanup-action@v1
with:
dry-run: ${{ github.event.inputs.dry-run || false }}
keep-n-tagged: 10
delete-tags: pr-*
exclude-tags: latest*,develop*,nightly*

# See: https://github.com/dataaxiom/ghcr-cleanup-action?tab=readme-ov-file#action-options
- name: Delete old nightly images
- if: always()
name: Delete old nightly images
uses: dataaxiom/ghcr-cleanup-action@v1
with:
dry-run: ${{ github.event.inputs.dry-run || false }}
keep-n-tagged: 10
delete-tags: nightly*
exclude-tags: latest*,develop*

# See: https://github.com/dataaxiom/ghcr-cleanup-action?tab=readme-ov-file#action-options
- name: Delete old develop images
- if: always()
name: Delete old develop images
uses: dataaxiom/ghcr-cleanup-action@v1
with:
dry-run: ${{ github.event.inputs.dry-run || false }}
keep-n-tagged: 10
delete-tags: develop*
exclude-tags: latest*,nightly*
Expand All @@ -50,15 +62,19 @@ jobs:
# The tool supports multi-arch images, so it checks if any untagged images is referenced
# by a tagged one before deleting - meaning that "untagged" here is NOT the same as the
# 'untagged images' tab in the GHCR UI
- name: "Delete all untagged images"
- if: always()
name: "Delete all untagged images"
uses: dataaxiom/ghcr-cleanup-action@v1
with:
dry-run: ${{ github.event.inputs.dry-run || false }}
keep-n-untagged: 10
delete-untagged: true

# See: https://github.com/dataaxiom/ghcr-cleanup-action?tab=readme-ov-file#action-options
- name: "Delete all invalid images"
- if: always()
name: "Delete all invalid images"
uses: dataaxiom/ghcr-cleanup-action@v1
with:
dry-run: ${{ github.event.inputs.dry-run || false }}
delete-ghost-images: true
delete-orphaned-images: true

0 comments on commit 9de3d84

Please sign in to comment.