ghcr-delete-image-action
ghcr-delete-image-action copied to clipboard
feat: support packages for a user
I skipped compiling to dist, let me know if I shall change anything.
Needed to update @actions/github to be able to use the endpoints.
fixes #5
Any updates on this? Having this feature would be very helpful.
Will take a look during the week!
First of all, thanks for the PR. This indeed seems very useful functionality!
Initial thoughts:
- I don’t really love the
isUser
boolean having to be passed all the way from the inputs. I wonder if there’s Github metadata/service we can use to deduce that so the user doesn’t have to specify it. - Wondering if we can add an unit test for it
ChatGPT says:
Certainly! Here's an example curl request using the GitHub API to verify if a repository is owned by a user or an organization:
curl -H "Authorization: Bearer YOUR_GITHUB_TOKEN" \
https://api.github.com/repos/OWNER/REPO \
| jq '.owner.type'
Replace YOUR_GITHUB_TOKEN
with your actual GitHub personal access token, OWNER
with the username or organization name that owns the repository, and REPO
with the name of the repository you want to check.
The jq
command at the end of the request is used to parse the JSON response and extract only the type
field of the owner
object, which will be either "User"
or "Organization"
. This will allow you to determine if the repository is owned by a user or an organization.
Make sure to include this curl request inside of a GitHub action or workflow file to automate the process!
@vlussenburg Isn't that similar to using ${{ github.repository_owner }}
or does it cover ANY owner instead of just the owner of the repo?
Found this other action that does something similar using Python and it works: https://github.com/chipkent/action-cleanup-package
@vlussenburg Isn't that similar to using
${{ github.repository_owner }}
or does it cover ANY owner instead of just the owner of the repo?Found this other action that does something similar using Python and it works: https://github.com/chipkent/action-cleanup-package
Good question. Will have to dive in later. Having said that I do like that example
Hey there, yeah the isUser
is kind of messy, but I at least wanted to submit a draft to implement this.
Looking up the repository with the owner would be a good idea. Would have to look into how the SDK treats the data here @actions/github
.
Could be a step to avoid hardcoding the names in yaml as well, when we would use the vars.