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

Automate GitHub App creation #22

Closed
npalm opened this issue May 14, 2020 · 8 comments
Closed

Automate GitHub App creation #22

npalm opened this issue May 14, 2020 · 8 comments
Labels
abandoned enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed Stale

Comments

@npalm
Copy link
Member

npalm commented May 14, 2020

Currently app creation is a manual process. Much better if we can automate the creation of an app.

@npalm npalm added enhancement New feature or request help wanted Extra attention is needed labels May 14, 2020
@blancsys
Copy link

blancsys commented Jul 23, 2020

Hi, I'm also trying to automate the GitHub App creation.

It seems like we can't use Terraform, the GitHub Terraform provider doesn't support GitHub Apps.

Have you been researching any alternatives? The GitHub API supports Apps but maybe there is a higher-level library or project I can use.

Thanks

@npalm
Copy link
Member Author

npalm commented Jul 23, 2020

Yes this is an issue high on my list! But not having the time yet todo some decent research.

The terraform provider does not support apps at all so that is no option. Another option to create an app is via an URL with parameters, or even better the API. The hard thing here is that it is actaully a process.

  1. Create the app and generate SSH key
  2. Output from step 1 is needed for the current module.
  3. Update the app with the output of the current module.

An option could be that we execute via terraform some local code (e.g. TypeScript) to interact with GitHub. In that case could integrate via a local provisioner the whole process via Terraform. Drawback is that local provisioners should be something like a last resort. An alternative could be a lambda that orchestrate the whole setup, but in that case the Lambda should also do the require updates for step 2 above. Which results in my opinion to a too complex solution. @blancsys do you see any other alternative?

@leoblanc
Copy link
Contributor

@npalm Thanks for your feedback! Yeah, it seems like it's a difficult problem to solve. This is a new area for me. Today I read about creating GitHub apps using manifests and how to use probot to implement them but I'm not sure if it can help to fully automate the App creation.

@npalm npalm added the good first issue Good for newcomers label Mar 8, 2021
@skyzyx
Copy link
Contributor

skyzyx commented Oct 20, 2021

Just started looking at the issues in this project today. I’ve actually implemented this. “Automate-by-default,” as they say.

It's not implemented as Terraform, which may be what you guys are expecting. But it's a Dockerized Go app that runs a miniature local web server, and walks you through the process of:

  1. Creating an OAuth app for authentication and performing actions on your behalf.
  2. Collecting the client ID and secret for the OAuth app and storing them.
  3. Bouncing you over to GHES to properly authenticate.
  4. Looks up the list of orgs you have admin access to, so that you can choose which one will host the GitHub App.
  5. Installs "part 1" of the app.
  6. Explains to you the commands to run to (a) generate the Lambda functions and copy them to the right place, and (b) run the Terraform to actually set everything up. (I haven't automated this part in the app, but the steps are simple.)
  7. Read the terraform output data for the webhook URL, and update the GitHub app with it (aka, "part 2" of the app).

As a maintainer/admin, you just need to install Docker Desktop (or just run dockerd if you're on Linux), boot the app, and follow the prompts.

All a user has to do is:

  1. Install the GitHub app in their org.
  2. Choose which repos should have access.

I manage a GHES installation, so that's what I wrote it for. Supporting self-hosted runners which talk to GitHub.com should be relatively low-effort to support (e.g., code, documentation, error messaging).

I can certainly clean up some of the rough code and open-source it. It probably doesn't belong in this core repo as-is, but as a "neighbor" repo managed by someone else. But I'm open if you'd be interested in adopting it.

@ScottGuymer
Copy link
Member

If this is still relevant, you can create a GH app from a manifest.

More info here https://docs.github.com/en/[email protected]/developers/apps/building-github-apps/creating-a-github-app-from-a-manifest

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs. Thank you for your contributions.

@lmilbaum
Copy link

Can you please share an example code/repo where such an app is created? It could help for inspiration. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abandoned enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed Stale
Projects
None yet
Development

No branches or pull requests

7 participants