Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/prune-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Prune packages

on:
workflow_dispatch:
schedule:
# 04:11 UTC on the first day of each month
- cron: '11 4 1 * *'

jobs:
list-packages:
runs-on: ubuntu-latest

outputs:
matrix: ${{ steps.make-matrix.outputs.matrix }}

steps:
- name: Build package-name matrix
id: make-matrix
uses: actions/github-script@v7
with:
script: |
// Fetch all container packages in this org/user
const response = await github.paginate(
"GET /orgs/{org}/packages",
{ org: context.repo.owner, package_type: "container", per_page: 100 }
);
// Extract unique names
const names = [...new Set(response.map(p => p.name))];
// Build matrix: one entry per package-name
const matrix = { include: names.map(n => ({ "package-name": n })) };
core.setOutput("matrix", JSON.stringify(matrix));

prune:
needs: list-packages
runs-on: ubuntu-latest

strategy:
matrix: ${{ fromJSON(needs.list-packages.outputs.matrix) }}
max-parallel: 4

steps:
- name: Delete old packages
uses: actions/delete-package-versions@v5
with:
package-name: ${{ matrix.package-name }}
package-type: nuget
min-versions-to-keep: 1