Skip to content

Prune Docker Tags

Prune Docker Tags #356

Workflow file for this run

name: Prune Docker Tags
on:
delete:
branches:
- '**'
jobs:
prune:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
const pkgs = await github.rest.packages.getAllPackageVersionsForPackageOwnedByOrg({
package_type: "container",
package_name: context.repo.repo,
org: context.repo.owner,
state: "active"
});
for (const pkg of pkgs.data) {
const tags = [context.ref, `${context.ref}-debug`]
for (const tag of tags) {
if (pkg.metadata.container.tags.includes(tag) || pkg.metadata.container.tags.includes(tag.replace("/", "-"))) {
await github.rest.packages.deletePackageVersionForOrg({
package_type: "container",
package_name: context.repo.repo,
org: context.repo.owner,
package_version_id: pkg.id
});
console.log(`Deleted package version: ${pkg.name}`);
}
}
}