octokit-provider.ts 564 B

1234567891011121314151617181920212223
  1. import * as github from '@actions/github'
  2. import {Octokit} from '@octokit/rest'
  3. import {getServerApiUrl} from './url-helper'
  4. // Centralize all Octokit references by re-exporting
  5. export {Octokit} from '@octokit/rest'
  6. export type OctokitOptions = {
  7. baseUrl?: string
  8. userAgent?: string
  9. }
  10. export function getOctokit(authToken: string, opts: OctokitOptions) {
  11. const options: Octokit.Options = {
  12. baseUrl: getServerApiUrl(opts.baseUrl)
  13. }
  14. if (opts.userAgent) {
  15. options.userAgent = opts.userAgent
  16. }
  17. return new github.GitHub(authToken, options)
  18. }