Skip to content

Commit

Permalink
WIP container cleanup script
Browse files Browse the repository at this point in the history
  • Loading branch information
rnijveld committed Apr 7, 2024
1 parent 0c7c80c commit 618ae9c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/container-cleanup.yml
Original file line number Diff line number Diff line change
@@ -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`);

0 comments on commit 618ae9c

Please sign in to comment.