diff --git a/docs/installation.md b/docs/installation.md index 9f7a7613..9a928cd5 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -33,7 +33,7 @@ Environment variables for the webhook process: `GITHUB_OAUTH_TOKEN` GitHub main OAuth token for all other GH operations -`GITHUB_HOST` URL for github API, needed for Github Enterprise Server, should include http scheme but no `/api/v3` path, e.g. :`https://my-gh-host.com/` +`GITHUB_HOST` Host name for github API, needed for Github Enterprise Server, should not include http scheme and path, e.g. :`my-gh-host.com` `GITHUB_WEBHOOK_SECRET` secret used to sign webhook payload to be validated by the WH server, must match the sting in repo settings/hooks page diff --git a/main.go b/main.go index 221141ed..5196f16e 100644 --- a/main.go +++ b/main.go @@ -116,8 +116,8 @@ func createGithubRestClient(tokenEnvVarName string, githubRestAltURL string, ctx return client } -func createGithubAppGraphQlClient(githubAppPrivateKeyPath string, githubGraphqlAltURL string, ctx context.Context) *githubv4.Client { - httpClient, _ := createGithubInstalltionHttpClient(githubAppPrivateKeyPath, githubGraphqlAltURL, ctx) +func createGithubAppGraphQlClient(githubAppPrivateKeyPath string, githubGraphqlAltURL string, githubRestAltURL string, ctx context.Context) *githubv4.Client { + httpClient, _ := createGithubInstalltionHttpClient(githubAppPrivateKeyPath, githubRestAltURL, ctx) var client *githubv4.Client if githubGraphqlAltURL != "" { client = githubv4.NewEnterpriseClient(githubGraphqlAltURL, httpClient) @@ -190,16 +190,17 @@ func main() { var githubRestAltURL string var githubGraphqlAltURL string if githubHost != "" { - githubRestAltURL = githubHost + "/api/v3" - githubGraphqlAltURL = githubHost + "api/graphql" + githubRestAltURL = "https://" + githubHost + "/api/v3" + githubGraphqlAltURL = "https://" + githubHost + "/api/graphql" log.Infof("Github REST API endpoint is configured to %s", githubRestAltURL) + log.Infof("Github graphql API endpoint is configured to %s", githubGraphqlAltURL) } else { log.Infof("Using public Github API endpoint") } if githubAppPrivateKeyPath != "" { log.Infoln("Using GH app auth") mainGithubClient = createGithubAppRestClient(githubAppPrivateKeyPath, githubRestAltURL, ctx) - githubGraphQlClient = createGithubAppGraphQlClient(githubAppPrivateKeyPath, githubGraphqlAltURL, ctx) + githubGraphQlClient = createGithubAppGraphQlClient(githubAppPrivateKeyPath, githubGraphqlAltURL, githubRestAltURL, ctx) } else { mainGithubClient = createGithubRestClient("GITHUB_OAUTH_TOKEN", githubRestAltURL, ctx) githubGraphQlClient = createGithubGraphQlClient("GITHUB_OAUTH_TOKEN", githubGraphqlAltURL)