Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expire CI images #35

Open
lloeki opened this issue Nov 26, 2024 · 0 comments
Open

Expire CI images #35

lloeki opened this issue Nov 26, 2024 · 0 comments

Comments

@lloeki
Copy link
Member

lloeki commented Nov 26, 2024

CI images build up over time.

These can be deleted after a certain time has elapsed, provided they don't exceed ghcr.io image deletion policy i.e have not been used too much which should be almost universally the case.

actions/delete-package-versions#101 prevents non-integers to be passed, so tags are not deleted. It seems v3.0.1 is not affected.

Since we have to list packages and filter by date, and the action does not support it, we might make use of this workaround:

curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>"\
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/orgs/ORGNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/versions

URL should be: https://api.github.com/ogs/DataDog/packages/container/PACKAGE_NAME/versions

This should return:

[
  {
    // ...
  },
  {
    "id": 12345678, // extract this to pass to action
    "name": "some-tag", // select on this
    // ...
  },
  // ...
]

Selectable via:

jq -r '.[] | select(.name == "some-tag").id'

Note: the query might be paginated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant