Skip to content

Commit

Permalink
Now?
Browse files Browse the repository at this point in the history
  • Loading branch information
Husky-Devel committed Nov 12, 2024
1 parent aaafc7e commit 5f9acd3
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions .github/workflows/dlold.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
name: Clean up old packages

on:
push:
tags:
- 'cr*'
branches:
- 'master'
- 'dev'
schedule:
- cron: '0 0 * * 0' # Run weekly on Sunday at midnight
workflow_dispatch: # Allow manual trigger
- cron: '0 0 * * 0'
workflow_dispatch:

jobs:
cleanup:
Expand All @@ -19,15 +13,36 @@ jobs:
contents: read

steps:
- name: Delete old packages
- name: Delete untagged and SHA packages
uses: actions/delete-package-versions@v5
with:
package-name: 10
package-type: 'container'
min-versions-to-keep: 10
delete-only-untagged-versions: false
min-versions-to-keep: 0
delete-only-untagged-versions: true # Target untagged/SHA versions
ignore-versions: |
master
dev
cr*
token: ${{ github.token }}

- name: Delete SHA tagged packages
uses: actions/github-script@v7
with:
script: |
const pkgs = await github.rest.packages.getAllPackageVersionsForPackageOwnedByOrg({
package_type: 'container',
package_name: '10',
org: context.repo.owner
});
for (const pkg of pkgs.data) {
if (pkg.metadata.container.tags.some(tag => tag.startsWith('sha256:'))) {
await github.rest.packages.deletePackageVersionForOrg({
package_type: 'container',
package_name: '10',
org: context.repo.owner,
package_version_id: pkg.id
});
}
}

0 comments on commit 5f9acd3

Please sign in to comment.