CI: nightly registry cleanup - prune hash images not release-tagged nor a branch head
CI / full-gate (push) Successful in 2m40s
Mirror / github-mirror (push) Successful in 0s

This commit was merged in pull request #6.
This commit is contained in:
2026-07-04 09:18:07 +02:00
parent 058280934b
commit 0644ec8f5a
7 changed files with 212 additions and 7 deletions
+31
View File
@@ -0,0 +1,31 @@
const hashTag = /^[0-9a-f]{40}$/;
const manifestVersion = /^sha256:[0-9a-f]{64}$/;
export type HashTagPlan = {
deletions: string[];
keptTags: string[];
};
export function planHashTagDeletions(input: {
branchHeadShas: string[];
releaseTagShas: string[];
versions: string[];
}): HashTagPlan {
const keep = new Set([...input.branchHeadShas, ...input.releaseTagShas]);
const deletions: string[] = [];
const keptTags: string[] = [];
for (const version of input.versions) {
if (manifestVersion.test(version)) continue;
if (hashTag.test(version) && !keep.has(version)) deletions.push(version);
else keptTags.push(version);
}
return { deletions, keptTags };
}
export function selectOrphanedManifests(input: {
referencedDigests: string[];
versions: string[];
}): string[] {
const referenced = new Set(input.referencedDigests);
return input.versions.filter((v) => manifestVersion.test(v) && !referenced.has(v));
}