@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
+44
View File
@@ -0,0 +1,44 @@
import * as Context from './context'
import * as Utils from './internal/utils'
// octokit + plugins
import {Octokit} from '@octokit/core'
import {OctokitOptions} from '@octokit/core/dist-types/types'
import {restEndpointMethods} from '@octokit/plugin-rest-endpoint-methods'
import {paginateRest} from '@octokit/plugin-paginate-rest'
export const context = new Context.Context()
const baseUrl = Utils.getApiBaseUrl()
const defaults = {
baseUrl,
request: {
agent: Utils.getProxyAgent(baseUrl)
}
}
export const GitHub = Octokit.plugin(
restEndpointMethods,
paginateRest
).defaults(defaults)
/**
* Convience function to correctly format Octokit Options to pass into the constructor.
*
* @param token the repo PAT or GITHUB_TOKEN
* @param options other options to set
*/
export function getOctokitOptions(
token: string,
options?: OctokitOptions
): OctokitOptions {
const opts = Object.assign({}, options || {}) // Shallow clone - don't mutate the object provided by the caller
// Auth
const auth = Utils.getAuthString(token, opts)
if (auth) {
opts.auth = auth
}
return opts
}