Skip to content

Commit 16fdb9c

Browse files
authored
Merge pull request #98 from nobbs/feat/github-enterprise
feat: add support for GitHub Enterprise
2 parents e1e5b4a + 7527dc3 commit 16fdb9c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

main.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
"golang.org/x/oauth2"
1717
)
1818

19+
const githubGraphQLURL = "https://api.github.com/graphql"
20+
1921
var version = "development"
2022

2123
var opts struct {
@@ -52,9 +54,17 @@ func main() {
5254
log.Fatal("GITHUB_TOKEN env var must be set")
5355
}
5456

57+
ghes := os.Getenv("GITHUB_GRAPHQL_URL")
58+
5559
tok := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: ght})
5660
httpClient := oauth2.NewClient(ctx, tok)
57-
client := githubv4.NewClient(httpClient)
61+
62+
var client *githubv4.Client
63+
if ghes == githubGraphQLURL {
64+
client = githubv4.NewClient(httpClient)
65+
} else {
66+
client = githubv4.NewEnterpriseClient(ghes, httpClient)
67+
}
5868

5969
// parse the commit message into headline and body
6070
headline, body := parseMessage(opts.Message)

0 commit comments

Comments
 (0)