diff --git a/.changeset/khaki-hotels-doubt.md b/.changeset/khaki-hotels-doubt.md new file mode 100644 index 0000000000..8bab499f3e --- /dev/null +++ b/.changeset/khaki-hotels-doubt.md @@ -0,0 +1,5 @@ +--- +'@backstage/integration': patch +--- + +Support selective GitHub app installation for GHE diff --git a/packages/integration/src/github/GithubCredentialsProvider.ts b/packages/integration/src/github/GithubCredentialsProvider.ts index 3156488ba7..62c7cd7a57 100644 --- a/packages/integration/src/github/GithubCredentialsProvider.ts +++ b/packages/integration/src/github/GithubCredentialsProvider.ts @@ -64,12 +64,14 @@ const HEADERS = { */ class GithubAppManager { private readonly appClient: Octokit; + private readonly baseUrl?: string; private readonly baseAuthConfig: { appId: number; privateKey: string }; private readonly cache = new Cache(); private readonly allowedInstallationOwners: string[] | undefined; // undefined allows all installations constructor(config: GithubAppConfig, baseUrl?: string) { this.allowedInstallationOwners = config.allowedInstallationOwners; + this.baseUrl = baseUrl; this.baseAuthConfig = { appId: config.appId, privateKey: config.privateKey, @@ -108,6 +110,7 @@ class GithubAppManager { }); if (repo && result.data.repository_selection === 'selected') { const installationClient = new Octokit({ + baseUrl: this.baseUrl, auth: result.data.token, }); const repos = await installationClient.paginate(