Skip to content

Commit ccb5eec

Browse files
authored
GitHub Enterprise Apps docs (#1211)
Adds some docs on how to use GitHub Enterprise Apps (i.e. add the GitHub App manually) Also mention how to set up an app-wide code host connection
1 parent 050cf99 commit ccb5eec

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

docs/admin/code_hosts/github.mdx

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ There are 2 ways to connect with GitHub:
2121

2222
{/* <!-- NOTE: The instructions in the following sections closely mirror those in doc/admin/config/batch_changes under "Commit signing for GitHub". When making changes here, be sure to consider if those changes should also be made over there! --> */}
2323

24+
There are two ways to connect a GitHub App:
25+
1. **[Create a new GitHub App](#creating-a-new-github-app)** via Sourcegraph, which will set up all of the required permissions and automatically retrieve the credentials
26+
2. **[Add an existing GitHub App](#adding-an-existing-github-app)** by providing the details of an existing GitHub App (required when using GitHub Enterprise Apps)
27+
28+
### Creating a new GitHub App
29+
2430
To create a GitHub App and connect it to Sourcegraph:
2531

2632
1. Go to **Site admin > Repositories > Github Apps** on Sourcegraph.
@@ -64,21 +70,29 @@ To create a GitHub App and connect it to Sourcegraph:
6470

6571
You can now [select repositories to sync](#selecting-repositories-to-sync) or see more configuration options in the [configuration section](#configuration).
6672

73+
#### Syncing repositories from all installations
74+
75+
When creating a code host connection for a GitHub App with multiple installations, you have two options:
76+
77+
1. **Sync from a specific installation**: Create a connection under a specific installation (as described above). This will only sync repositories from that particular installation.
78+
79+
2. **Sync from all installations**: Create a connection that syncs repositories from all installations of the GitHub App by omitting the `installationID` field in the connection configuration. This is useful when you want a single connection to handle repositories across multiple organizations or user accounts.
80+
6781
9. (Optional) If you want to sync repositories from other organization or user namespaces and your GitHub App is set to public visibility, you can create additional installations with **Add installation**.
6882

6983
> NOTE: When you create a GitHub App, Sourcegraph automatically sets up an [incoming webhook](/admin/config/webhooks/incoming) for the app. This webhook subscribes to events for any repository or organization the app has access to, allowing Sourcegraph to keep repository and permission data in sync with GitHub.
7084
7185
> NOTE: If you are using [Batch Changes](/batch-changes/), you can create a GitHub App to perform [commit signing](/admin/config/batch_changes#commit-signing-for-github) (Beta).
7286
73-
### Multiple installations
87+
#### Multiple installations
7488

7589
The initial GitHub App setup will only install the App on the organization or user account that you registered it with. If your code is spread across multiple organizations or user accounts, you will need to create additional installations for each namespace that you want Sourcegraph to sync repositories from.
7690

7791
By default, Sourcegraph creates a private GitHub App, which only allows the App to be installed on the same organization or user account that it was created in. If you did not set the App to public visibility during creation, you will need to [change the visibility](https://docs.github.com/en/apps/maintaining-github-apps/modifying-a-github-app#changing-the-visibility-of-a-github-app) to public before you can install it in other namespaces. For security considerations, see [GitHub's documentation on private vs public apps](https://docs.github.com/en/apps/creating-github-apps/setting-up-a-github-app/making-a-github-app-public-or-private).
7892

7993
Once public, App can be installed in additional namespaces either from Sourcegraph or from GitHub.
8094

81-
#### Installing from Sourcegraph
95+
##### Installing from Sourcegraph
8296

8397
1. Go to **Site admin > Repositories > Github Apps** and click **Edit** on the App you want to install in another namespace. You'll be taken to the App details page.
8498

@@ -99,7 +113,7 @@ Once public, App can be installed in additional namespaces either from Sourcegra
99113

100114
4. To sync repositories from this installation, click **Add connection** under your new installation.
101115

102-
#### Installing from GitHub
116+
##### Installing from GitHub
103117

104118
1. Go to the GitHub App page. You can get here easily from Sourcegraph by clicking **View in GitHub** for the App you want to install in another namespace.
105119
2. Click **Configure**, or go to **App settings > Install App**, and select the organization or user account you want to install the App on.
@@ -111,10 +125,40 @@ Once public, App can be installed in additional namespaces either from Sourcegra
111125

112126
5. To sync repositories from this installation, click **Add connection** under your new installation.
113127

128+
### Adding an existing GitHub App
129+
130+
If you have an existing GitHub App (such as a GitHub Enterprise App), you can connect it to Sourcegraph by providing its details manually. This is particularly useful for:
131+
132+
- **GitHub Enterprise Apps**: Apps that can be installed across multiple organizations within an enterprise account while maintaining private visibility
133+
- **Existing GitHub Apps**: Apps that were created outside of Sourcegraph that you want to use for repository syncing
134+
135+
To add an existing GitHub App:
136+
137+
1. Go to **Site admin > Repositories > Github Apps** on Sourcegraph.
138+
2. Click **Add an existing GitHub App**.
139+
3. Enter the following details of your existing GitHub App:
140+
- **GitHub URL**: The URL of your GitHub instance (e.g., `https://github.com` or `https://github-enterprise.example.com`)
141+
- **Client ID**: The unique identifier for your GitHub App
142+
- **Private Key**: The private key generated for your GitHub App (in PEM format)
143+
4. Click **Add GitHub App** to save the configuration.
144+
5. Once added, you can manage installations and create code host connections just like with apps created through Sourcegraph.
145+
146+
> NOTE: You'll still need to create a client secret on GitHub and [set up an auth provider](/admin/auth#github) if you would like to enable repository permissions.
147+
148+
When creating code host connections for your existing GitHub App, you can choose to sync repositories from a specific installation or from all installations by omitting the `installationID` field (see [Syncing repositories from all installations](#syncing-repositories-from-all-installations)).
149+
150+
> NOTE: For GitHub Enterprise Apps, this method allows you to use a single app across multiple organizations within your enterprise, avoiding the need to create separate public apps or multiple private apps for each organization.
151+
152+
> NOTE: Make sure your existing GitHub App has the required permissions listed in the [Creating a new GitHub App](#creating-a-new-github-app) section.
153+
114154
### Configuring Multiple Private GitHub Apps for Sourcegraph
115155
If you prefer not to make your GitHub App public and instead create separate private GitHub Apps for each organizations, users will need to authorize each GitHub App individually to ensure proper repository access and permissions syncing. This is because GitHub Apps have narrowly scoped permissions and do not share authentication across multiple installations. To streamline this process, users can go to `User Settings` > `Account Security` in Sourcegraph and connect all necessary GitHub Apps from there. Once authorized, Sourcegraph will use the user's GitHub identity to determine access across all configured GitHub Apps.
116156

117-
For customers using GitHub Enterprise Cloud, an alternative approach is to create an Enterprise GitHub App, which can be installed across multiple organizations within an enterprise account while maintaining private visibility. More details on this approach can be found in [GitHub's documentation](https://docs.github.com/en/enterprise-cloud@latest/admin/managing-your-enterprise-account/creating-github-apps-for-your-enterprise).
157+
**GitHub Enterprise Apps**: For customers using GitHub Enterprise Cloud, we recommend creating a GitHub Enterprise App, which can be installed across multiple organizations within an enterprise account while maintaining private visibility. This eliminates the need to create separate apps for each organization or make your app public.
158+
159+
To use a GitHub Enterprise App with Sourcegraph:
160+
1. Create the Enterprise App in your GitHub Enterprise settings (see [GitHub's documentation](https://docs.github.com/en/enterprise-cloud@latest/admin/managing-your-enterprise-account/creating-github-apps-for-your-enterprise))
161+
2. Use the [**Add an existing GitHub App**](#adding-an-existing-github-app) option in Sourcegraph to connect it
118162

119163
### Uninstalling an App
120164

0 commit comments

Comments
 (0)