feat: infer github server and api urls

This commit is contained in:
Peter Evans
2023-12-19 09:39:50 +00:00
parent 02a8f71e34
commit 1e6bff9d94
9 changed files with 431 additions and 401 deletions

View File

@ -20,12 +20,16 @@ interface Pull {
export class GitHubHelper {
private octokit: InstanceType<typeof Octokit>
constructor(token: string) {
constructor(githubServerHostname: string, token: string) {
const options: OctokitOptions = {}
if (token) {
options.auth = `${token}`
}
options.baseUrl = process.env['GITHUB_API_URL'] || 'https://api.github.com'
if (githubServerHostname !== 'github.com') {
options.baseUrl = `https://${githubServerHostname}/api/v3`
} else {
options.baseUrl = 'https://api.github.com'
}
this.octokit = new Octokit(options)
}