How to create Organization name through Github API instead of creating manually?

前端 未结 4 1398
深忆病人
深忆病人 2020-12-20 02:22

I am trying to use github api to create organization and repositories instead of creating them manually. I was looking at this site which talks about how to create repositor

相关标签:
4条回答
  • 2020-12-20 02:47

    GitHub doesn't privide a public api for that.

    But say if you want to automate the organization creation process, you can inspect the network activity (press F12 in your browser and navigate to the network tab) on this page

    https://github.com/account/organizations/new

    to find out the private api for checking name availability and creating an organization, then export the request as curl command, put it in a shell script and parameterize the organization name.

    I won't go into details or post my script here because the script is fairly to trivial to write and it will leak my browser cookie and session information

    btw if you are using GitHub Enterprise then it's documented here

    https://developer.github.com/enterprise/2.16/v3/enterprise-admin/orgs/ https://github.com/aws-quickstart/quickstart-github-enterprise/blob/master/scripts/adminuser_org_repo.sh

    Update:

    WARNING!!! Be careful not to create too many organizations. I currently have created over 500+ organizations with my personal account. Now each time I visit a page on github with my account logged in, it will either take seconds to load or doesn't load at all, showing the unicorn page like https://github.com/503.html. If I log out of my account, the page loads quickly again. I've pretty much given up using the github web ui.

    0 讨论(0)
  • 2020-12-20 02:51

    You could try something like this

    curl --include -u victor-raul-hernandez-contreras:your-personal-access-token-here -X POST https://github.hpe.com/api/v3/admin/organizations --data '{"login":"loko200","profile_name":"lokosoft, inc.", "admin":"victor-raul-hernandez-contreras"}'
    

    It worked for me at github enterprise.

    0 讨论(0)
  • 2020-12-20 02:55

    Is there any way to create organization name as well through github API?

    Currently it's not possible to create organizations nor user accounts via the GitHub API.

    0 讨论(0)
  • 2020-12-20 03:05

    You can check out how a wrapper like go-gihub proposes to manage an organization, reflecting the Organization API.

    You can list, get or edit an organization, but apparently not create one.

    0 讨论(0)
提交回复
热议问题