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

feat: support packages for a user #168

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lazyfrosch
Copy link

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

@lazyfrosch lazyfrosch mentioned this pull request Mar 26, 2023
@gaby
Copy link

gaby commented Apr 17, 2023

Any updates on this? Having this feature would be very helpful.

@vlussenburg
Copy link
Collaborator

vlussenburg commented Apr 17, 2023

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

@vlussenburg
Copy link
Collaborator

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!

@gaby
Copy link

gaby commented Apr 17, 2023

@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
Copy link
Collaborator

@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

@lazyfrosch
Copy link
Author

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.

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

Successfully merging this pull request may close these issues.

Support user owner
3 participants