mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-01 21:13:17 +08:00
@actions/github v3 using Octokit/core (#453)
* Rebuild to use @Octokit/Core
This commit is contained in:
25
packages/github/src/internal/utils.ts
Normal file
25
packages/github/src/internal/utils.ts
Normal 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'
|
||||
}
|
||||
Reference in New Issue
Block a user