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

Add keep-last input #4

Closed
vlaurin opened this issue Jul 8, 2021 · 7 comments · Fixed by #5
Closed

Add keep-last input #4

vlaurin opened this issue Jul 8, 2021 · 7 comments · Fixed by #5
Assignees
Labels

Comments

@vlaurin
Copy link
Owner

vlaurin commented Jul 8, 2021

Optional input defaulting to 0. Define the count of qualifying, most recent versions to keep.

Example

To keep the last 5 untagged versions which are older than 7 days:

steps:
  - name: Prune
    uses: vlaurin/action-ghcr-prune@main
    with:
      token: ${{ secrets.YOUR_TOKEN }}
      organization: your-org
      container: your-container
      older-than: 7 # days
      untagged: true
      keep-last: 5
@TROEERI
Copy link

TROEERI commented Aug 4, 2021

This would be a feature needed to make this action applicable for our use-case.

@vlaurin vlaurin self-assigned this Aug 4, 2021
vlaurin added a commit that referenced this issue Aug 5, 2021
Relates to #3 and prepares for #4
vlaurin added a commit that referenced this issue Aug 5, 2021
Resolves #4
The option defaults to 0 to preserve existing behaviour when not set.
vlaurin added a commit that referenced this issue Aug 5, 2021
Resolves #4
The option defaults to 0 to preserve existing behaviour when not set.
@vlaurin
Copy link
Owner Author

vlaurin commented Aug 5, 2021

@TROEERI I'm still testing it, but if you want to have a go at using it you can do so using my branch:

      - uses: vlaurin/action-ghcr-prune@4-keep-last
        name: Prune untagged images after 1 day, except 2 most recent
        with:
          token: ${{ secrets.YOUR_TOKEN }}
          organization: your-org
          container: your-container
          dry-run: true
          older-than: 1 # days
          keep-last: 2
          untagged: true

Feedback welcome, if all good I can release it today.

@vlaurin vlaurin closed this as completed in #5 Aug 5, 2021
vlaurin added a commit that referenced this issue Aug 5, 2021
Relates to #3 and prepares for #4
vlaurin added a commit that referenced this issue Aug 5, 2021
Resolves #4
The option defaults to 0 to preserve existing behaviour when not set.
@vlaurin
Copy link
Owner Author

vlaurin commented Aug 5, 2021

@TROEERI published as v0.2.0

@TROEERI
Copy link

TROEERI commented Aug 6, 2021 via email

@vlaurin
Copy link
Owner Author

vlaurin commented Aug 6, 2021

@TROEERI Given the error is about the package not being found, the only thing that comes to mind is permissions of the token being used?

The action uses the Github Rest API deletePackageVersionForOrg() resource which states:

To use this endpoint, you must have admin permissions in the organization and authenticate using an access token with the packages:read and packages:delete scopes. In addition:
[...]
If package_type is container, you must also have admin permissions to the container you want to delete.

So the token used must be for a user having admin permissions both on the organisation and the container, could that be the issue?

@TROEERI
Copy link

TROEERI commented Aug 6, 2021 via email

@vlaurin
Copy link
Owner Author

vlaurin commented Aug 6, 2021

Great, thank you for confirming, I'm adding that to the README.

vlaurin added a commit that referenced this issue Aug 6, 2021
As per feedback on #4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants