Skip to content

Expire CI images #35

@lloeki

Description

@lloeki

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions