-
Notifications
You must be signed in to change notification settings - Fork 0
35 lines (32 loc) · 1.24 KB
/
prune-docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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}`);
}
}
}