mirror of
https://github.com/actions/checkout.git
synced 2026-01-21 16:18:54 +08:00
Adding ability to specify the GitHub Server URL and allowing for it to differ from the Actions workflow host
This commit is contained in:
parent
2541b1294d
commit
385d3aa94f
13 changed files with 182 additions and 62 deletions
23
src/octokit-helper.ts
Normal file
23
src/octokit-helper.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import * as github from '@actions/github'
|
||||
import {Octokit} from '@octokit/rest'
|
||||
import {getServerApiUrl} from './url-helper'
|
||||
|
||||
// Centralize all Octokit references by re-exporting
|
||||
export {Octokit} from '@octokit/rest'
|
||||
|
||||
export type OctokitOptions = {
|
||||
baseUrl?: string
|
||||
userAgent?: string
|
||||
}
|
||||
|
||||
export function getOctokit(authToken: string, opts: OctokitOptions) {
|
||||
const options: Octokit.Options = {
|
||||
baseUrl: getServerApiUrl(opts.baseUrl)
|
||||
}
|
||||
|
||||
if (opts.userAgent) {
|
||||
options.userAgent = opts.userAgent
|
||||
}
|
||||
|
||||
return new github.GitHub(authToken, options)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue