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

Do you really need a personal access token? #27

Open
sihil opened this issue Mar 16, 2022 · 13 comments
Open

Do you really need a personal access token? #27

sihil opened this issue Mar 16, 2022 · 13 comments

Comments

@sihil
Copy link

sihil commented Mar 16, 2022

This looks really useful although I'm very reluctant to create a PAT.

Have you experimented to see whether this can be replaced with a packages: write permission? i.e.

name: Delete old container images

on:
  schedule:
    - cron: '0 0 * * *'  # every day at midnight

permissions:
  packages: write

jobs:
  clean-ghcr:
    name: Delete old unused container images
    runs-on: ubuntu-latest
    steps:
      - name: Delete 'dev' containers older than a week
        uses: snok/container-retention-policy@v1
        with:
          image-names: python-dev, js-dev
          cut-off: A week ago UTC
          account-type: org
          org-name: my-org
          keep-at-least: 1
          untagged-only: true

This certainly lets you push and pull containers but I don't know if delete is included in write. I wondered if you knew one way or the other.

@sondrelg
Copy link
Member

Things change all the time, but last time I checked a PAT was required. Definitely understand your hesitation though - not entirely comfortable with it either.

@sihil
Copy link
Author

sihil commented Mar 16, 2022

Thanks for the quick reply. I will experiment and feedback just in case it has changed.

@sondrelg
Copy link
Member

Please do 🥇 And I guess we can leave this open for a while in case anyone else has relevant input 👍

@sihil
Copy link
Author

sihil commented Mar 18, 2022

It hasn't changed. A personal access token is still required 😢

Would be great to understand if packages/delete will make it to the GITHUB_TOKEN permissions anytime soon @NamrataJha et al.

@sihil sihil closed this as completed Mar 18, 2022
@sihil sihil reopened this Mar 18, 2022
@andygrunwald
Copy link
Contributor

I can confirm that, at the moment, an own personal access token with packages: delete permission is required.

GITHUB_TOKEN is not enough at the current moment.

@tuler
Copy link

tuler commented Aug 18, 2022

This GitHub blog post states GITHUB_TOKEN is supported in delete operations

@sondrelg
Copy link
Member

sondrelg commented Sep 3, 2022

I just tried switching in one of my workflows, and it resulted in a 500 internal server error 🤔

@timofey-drozhzhin
Copy link

timofey-drozhzhin commented Sep 13, 2022

This GitHub blog post states GITHUB_TOKEN is supported in delete operations

The article is referring to a different type of API endpoint used by docker CLI to login, push, pull, rm images... that type of API is in fact supported by ${{ secrets.GITHUB_TOKEN }} and is used by Docker Login Action. However, afaik, docker cannot remove container images from private repositories.

To delete private container images, you need access via api.github.com REST API endpoint, which as of now is not supported by ${{ secrets.GITHUB_TOKEN }}.

makkes added a commit to makkes/cerebro that referenced this issue Feb 10, 2023
@ruffsl
Copy link

ruffsl commented Mar 15, 2023

It hasn't changed. A personal access token is still required 😢

I've opened a community discussion on this topic over here:

Feel free to comment on or upvote the discussion to boost it's visibility/priority.

@ad-m-ss
Copy link
Contributor

ad-m-ss commented Apr 14, 2023

Did anyone test fine-grained tokens https://github.blog/2022-10-18-introducing-fine-grained-personal-access-tokens-for-github/ for that?

@rob-whittle
Copy link

Not sure if something has changed with the API, but the github provided action for cleaning up packages does work with the standard runner token. As does this action.

Unfortunately neither provide the option for excluding an image from deletion by tag 😞 .

@0x2b3bfa0
Copy link

0x2b3bfa0 commented Sep 25, 2023

The other actions query the packages individually, and that operation works with the default token, as long as the repository can manage its own packages:

This action doesn't have an easy migration path to the latter, because it also supports regular expressions for package names.

@mering
Copy link

mering commented Oct 31, 2023

@0x2b3bfa0 this is also my observation. In case we can identify the special case of only completely specified package names, it should be possible to use without a PAT similar to what I did in Chizkiyahu/delete-untagged-ghcr-action@3202d05.

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

10 participants