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

How to create a repository by Github App? #271

Closed
hcuong opened this issue Apr 1, 2021 · 4 comments
Closed

How to create a repository by Github App? #271

hcuong opened this issue Apr 1, 2021 · 4 comments
Projects

Comments

@hcuong
Copy link

hcuong commented Apr 1, 2021

I went through Github API and found some API that we could create a repository like:

https://docs.github.com/en/rest/reference/repos#create-a-repository-using-a-template
https://docs.github.com/en/rest/reference/repos#create-an-organization-repository
https://docs.github.com/en/rest/reference/repos#create-a-repository-for-the-authenticated-user

But it seems for only OAuth App that we need to scope repo permission on that.

I wonder is there a way we can do it on Github App with some kind of app token or installation token? If that we could install the new repository to the App also. It could be amazing fit to my use case.

@ghost ghost added this to Inbox in JS Apr 1, 2021
@magiclisten
Copy link

I tried with this in my backend but it returned 403:

    const installationOctokit = new Octokit({
      authStrategy: createAppAuth,
      auth: {
        appId,
        privateKey,
        installationId,
      },
    });

    const { data } = await installationOctokit.request('POST /orgs/{org}/repos', {
      org,
      name,
    });

I just found that there are an App could do it is Stackbit. Don't know how they could get that.

@gr2m
Copy link
Contributor

gr2m commented Apr 1, 2021

your app/installation needs the administration permission in order to create a repository in an organization. And I think you have to install the app on all your repositories.

It does not seem to be possible for user repositories

@gr2m
Copy link
Contributor

gr2m commented Apr 1, 2021

by the way this is rather a question for GitHub's platform APIs, not Octokit. I'm trying to help the best I can, but the GitHub folks monitoring https://github.community/c/github-ecosystem/37 have better insights and access to the teams working on these features.

@magiclisten
Copy link

Thanks @gr2m , appreciate it. I'll try more and close the issue.

@hcuong hcuong closed this as completed Apr 2, 2021
JS automation moved this from Inbox to Done Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
JS
  
Done
Development

No branches or pull requests

3 participants