@actions/github v3 using Octokit/core (#453)

* Rebuild to use @Octokit/Core
This commit is contained in:
Thomas Boop
2020-06-02 21:39:46 -04:00
committed by GitHub
parent 9ba7c679ad
commit 4a89cf72de
8 changed files with 311 additions and 319 deletions

View File

@@ -0,0 +1,25 @@
import * as http from 'http'
import * as httpClient from '@actions/http-client'
import {OctokitOptions} from '@octokit/core/dist-types/types'
export function getAuthString(
token: string,
options: OctokitOptions
): string | undefined {
if (!token && !options.auth) {
throw new Error('Parameter token or opts.auth is required')
} else if (token && options.auth) {
throw new Error('Parameters token and opts.auth may not both be specified')
}
return typeof options.auth === 'string' ? options.auth : `token ${token}`
}
export function getProxyAgent(destinationUrl: string): http.Agent {
const hc = new httpClient.HttpClient()
return hc.getAgent(destinationUrl)
}
export function getApiBaseUrl(): string {
return process.env['GITHUB_API_URL'] || 'https://api.github.com'
}