package github import ( "crypto/tls" "net/http" "net/url" "gitea.com/gitea/pr-deployer/pkgs/proxy" "gitea.com/gitea/pr-deployer/pkgs/settings" "github.com/google/go-github/v39/github" "golang.org/x/oauth2" ) func GetGithubClient(token *oauth2.Token) *github.Client { ts := oauth2.StaticTokenSource(token) var client = &http.Client{ Transport: &oauth2.Transport{ Base: &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, Proxy: func(req *http.Request) (*url.URL, error) { return proxy.Proxy()(req) }, }, Source: oauth2.ReuseTokenSource(nil, ts), }, } githubClient := github.NewClient(client) if settings.BaseURL != "https://github.com" { githubClient, _ = github.NewEnterpriseClient(settings.BaseURL, settings.BaseURL, client) } return githubClient }