delete old unused container images #66
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: delete old unused container images | |
on: | |
schedule: | |
- cron: "0 13 * * 1" | |
# Every Monday at 1PM UTC (9AM EST) | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: 'Log level' | |
required: true | |
default: 'warning' | |
type: choice | |
options: | |
- info | |
- warning | |
- debug | |
jobs: | |
list_package_info: | |
runs-on: ubuntu-latest | |
permissions: {} | |
# Get the name of the "image-name" of the package which will be "opticalaberrations" see https://github.com/abcucberkeley?tab=packages | |
# | |
# Then list the latest 10 "versions" of the package, like: | |
# https://github.com/abcucberkeley/opticalaberrations/pkgs/container/opticalaberrations/versions | |
# Only the latest will have "tags", old versions will be untagged, hence delete untagged-only. | |
# The "id" is here: "id":169696677. | |
steps: | |
- env: | |
GH_TOKEN: ${{ secrets.cleanup_packages }} | |
run: | | |
gh api /user/packages?package_type=container | |
gh api /user/packages/container/opticalaberrations/versions?per_page=10 | |
clean-ghcr: | |
name: Delete old unused container images | |
runs-on: ubuntu-latest | |
steps: | |
- name: Delete old images | |
# uses: snok/container-retention-policy@v2 | |
uses: snok/container-retention-policy@main | |
with: | |
image-names: opticalaberrations | |
cut-off: 1w | |
keep-n-most-recent: 3 | |
account: user | |
token: ${{ secrets.cleanup_packages }} | |
tag-selection: untagged |