Skip to content

Commit 5d54835

Browse files
committed
fix Enterprise server URL
1 parent 4f1479b commit 5d54835

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

src/acigithub/github-client.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"log"
88
"os"
9-
"strings"
109

1110
"github.com/google/go-github/v39/github"
1211
"golang.org/x/oauth2"
@@ -15,7 +14,7 @@ import (
1514
var (
1615
GithubClient *github.Client
1716
ctx = context.Background()
18-
githubServerUrl, isgithubServerUrl = os.LookupEnv("GITHUB_ENTERPRISE_SERVER_URL")
17+
githubServerUrl, isgithubServerUrl = os.LookupEnv("GITHUB_SERVER_URL")
1918
githubRepository, isgithubRepository = os.LookupEnv("GITHUB_REPOSITORY")
2019
githubToken, isgithubToken = os.LookupEnv("GITHUB_TOKEN")
2120
owner, repo string
@@ -34,15 +33,14 @@ func NewGitHubClient() (githubClient *github.Client, err error) {
3433
)
3534
githubTc := oauth2.NewClient(context.Background(), gitHubTs)
3635

37-
if !strings.HasSuffix(githubServerUrl, "/") {
38-
githubServerUrl = githubServerUrl + "/"
39-
}
40-
uploadUrl := fmt.Sprintf("%sapi/uploads/", githubServerUrl)
41-
4236
if isgithubServerUrl {
43-
githubClient, err = github.NewEnterpriseClient(githubServerUrl, uploadUrl, githubTc)
44-
if err != nil {
45-
return nil, fmt.Errorf("error at initializing github client: %v", err)
37+
if githubServerUrl != "https://github.com" {
38+
githubClient, err = github.NewEnterpriseClient(githubServerUrl, githubServerUrl, githubTc)
39+
if err != nil {
40+
return nil, fmt.Errorf("error at initializing github client: %v", err)
41+
}
42+
} else {
43+
githubClient = github.NewClient(githubTc)
4644
}
4745
} else {
4846
githubClient = github.NewClient(githubTc)

0 commit comments

Comments
 (0)