From 618ae9c9e0c8a03592b3978b00ea7f4fbc8986a6 Mon Sep 17 00:00:00 2001 From: Ruben Nijveld Date: Sun, 7 Apr 2024 20:53:17 +0200 Subject: [PATCH] WIP container cleanup script --- .github/workflows/container-cleanup.yml | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/container-cleanup.yml diff --git a/.github/workflows/container-cleanup.yml b/.github/workflows/container-cleanup.yml new file mode 100644 index 0000000..b71717f --- /dev/null +++ b/.github/workflows/container-cleanup.yml @@ -0,0 +1,31 @@ +name: Container Cleanup + +permissions: + contents: read + +on: + pull_request: + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - name: Get a list of untagged docker images + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea + with: + script: | + const versions = await github.rest.packages.getAllPackageVersionsForPackageOwnedByOrg({ + package_type: 'container', + package_name: 'debian', + org: context.repo.owner, + per_page: 100, + state: 'active', + }); + const to_remove = []; + for (const p of versions.data) { + if ((p.metadata?.container?.tags ?? []).length === 0) { + to_remove.push(p.name); + } + } + console.log(`Found ${to_remove.length} untagged container images to remove`); +