Skip to content

Commit

Permalink
Add Ghcr clean-up workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 committed Nov 2, 2023
1 parent f58dd27 commit 3b11a83
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ghcr-cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Delete old ghcr images
on:
schedule:
- cron: "15 1 * * *" # every day at 1:15am
pull_request:
types: [closed]
workflow_dispatch:

jobs:
ghcr-cleanup:
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
name: Delete old vnext images
runs-on: ubuntu-latest
steps:
- name: Delete older than a month vnext images
uses: snok/container-retention-policy@v2
with:
image-names: device/*
cut-off: One month ago UTC
account-type: org
org-name: plgd-dev
filter-tags: vnext-*
skip-tags: main,latest
token: ${{ secrets.GHCR_CLEANUP_PAT }}

- name: Set up Docker Buildx for delete untagged images action
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry for delete untagged images action
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_CLEANUP_PAT }}

- name: Delete untagged images with no dependency
uses: Chizkiyahu/delete-untagged-ghcr-action@v3
with:
repository: ${{ github.repository }}
repository_owner: ${{ github.repository_owner }}
token: ${{ secrets.GHCR_CLEANUP_PAT }}
owner_type: org
untagged_only: true
except_untagged_multiplatform: true

0 comments on commit 3b11a83

Please sign in to comment.