2019-07-29 17:09:32 +00:00
|
|
|
import * as Context from './context'
|
2020-06-03 01:39:46 +00:00
|
|
|
import {GitHub, getOctokitOptions} from './utils'
|
2019-07-29 17:09:32 +00:00
|
|
|
|
2020-06-03 01:39:46 +00:00
|
|
|
// octokit + plugins
|
2022-09-22 20:43:54 +00:00
|
|
|
import {OctokitOptions, OctokitPlugin} from '@octokit/core/dist-types/types'
|
2019-07-29 17:09:32 +00:00
|
|
|
|
2019-08-05 12:53:51 +00:00
|
|
|
export const context = new Context.Context()
|
2019-07-29 17:09:32 +00:00
|
|
|
|
2020-06-03 01:39:46 +00:00
|
|
|
/**
|
|
|
|
* Returns a hydrated octokit ready to use for GitHub Actions
|
|
|
|
*
|
|
|
|
* @param token the repo PAT or GITHUB_TOKEN
|
|
|
|
* @param options other options to set
|
|
|
|
*/
|
|
|
|
export function getOctokit(
|
|
|
|
token: string,
|
2022-09-22 20:43:54 +00:00
|
|
|
options?: OctokitOptions,
|
|
|
|
...additionalPlugins: OctokitPlugin[]
|
2020-06-03 01:39:46 +00:00
|
|
|
): InstanceType<typeof GitHub> {
|
2022-09-22 20:43:54 +00:00
|
|
|
const GitHubWithPlugins = GitHub.plugin(...additionalPlugins)
|
|
|
|
return new GitHubWithPlugins(getOctokitOptions(token, options))
|
2019-07-29 17:09:32 +00:00
|
|
|
}
|