Skip to content

older-than + keep-n-tagged options delete more recent images instead of the oldest ones #99

@artazar

Description

@artazar

Hi,

This log snippet perfectly shows the issue:

2025-09-10T03:32:09.0599816Z ##[group][my-example-image] Finding images that are older than: 1 month
2025-09-10T03:32:09.0601005Z sha256:43bdd2f64fd430966238c3e980f09bdc6dedff6f46a0c45ea0e8c362abf61dd7 0.6,latest,main
2025-09-10T03:32:09.0601974Z sha256:a3aa8e3f75379020d878cc11b996e6e5b4dd09e5bbb0c200385fe4a1709371be 0.5
2025-09-10T03:32:09.0602828Z sha256:0760896afc6712824ac6bff15b668053a71b3c2a2d86c8c744922cf7a507465b 0.4
2025-09-10T03:32:09.0603948Z sha256:e00d58f303186665528783c2b10a66ec367bfec7615234c54bc1568e6f4eb8a2 0.3
2025-09-10T03:32:09.0604612Z sha256:46ed7460d788b7e28e13f11b05225178a9d19d094d7fca110cd38e082f7ad6b0 0.2
2025-09-10T03:32:09.0605277Z sha256:3edd1d747b95124c8aa991228dd38618ed68ee769c36d963385069cf9ef874c5 5471674518
2025-09-10T03:32:09.0605986Z sha256:e7ee86f75c7b8c38f765453747b51eaa92066b9dbc04b721651d5129a001ada8 5463244641
2025-09-10T03:32:09.0606839Z sha256:67d21033dc62baf111dd6a0c08ab98be790828c833ceeddc638b1ebbcf52e141 5286500783
2025-09-10T03:32:09.0607409Z ##[endgroup]
2025-09-10T03:32:09.0607799Z ##[group][my-example-image] Untagging images: 0.6
2025-09-10T03:32:09.0608118Z 0.6

Here's my action definition:

      - uses: dataaxiom/ghcr-cleanup-action@v1
        with:
          token: ${{ secrets.TOKEN_RW }}
          packages: '(my-example-.*|my-first-repo/.*|my-second-repo/.*)'
          expand-packages: true
          keep-n-tagged: 5
          delete-tags: '^([0-9]*\.)*[0-9]+\.[0-9]+$'
          use-regex: true
          exclude-tags: develop, stage, main
          older-than: 1 month

I would expect the action to delete version 0.2 but not 0.6 as it's the latest one (and also tagged with "latest" and "main" tags).

Is it a sorting issue or should I use some different combination of settings to achieve that?

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