From 7527dc31ad4799b373c00c6a70bfc8a9a686b7c4 Mon Sep 17 00:00:00 2001 From: Alexej Disterhoft Date: Mon, 13 Jan 2025 15:50:50 +0100 Subject: [PATCH] feat: add support for GitHub Enterprise --- main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 870048a..1c288f9 100644 --- a/main.go +++ b/main.go @@ -16,6 +16,8 @@ import ( "golang.org/x/oauth2" ) +const githubGraphQLURL = "https://api.github.com/graphql" + var version = "development" var opts struct { @@ -52,9 +54,17 @@ func main() { log.Fatal("GITHUB_TOKEN env var must be set") } + ghes := os.Getenv("GITHUB_GRAPHQL_URL") + tok := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: ght}) httpClient := oauth2.NewClient(ctx, tok) - client := githubv4.NewClient(httpClient) + + var client *githubv4.Client + if ghes == githubGraphQLURL { + client = githubv4.NewClient(httpClient) + } else { + client = githubv4.NewEnterpriseClient(ghes, httpClient) + } // parse the commit message into headline and body headline, body := parseMessage(opts.Message)