Use the API URL from the environment if it is present.
This commit is contained in:
parent
a6d09016e7
commit
bbdc9efa94
42 changed files with 122 additions and 22 deletions
10
lib/api-client.js
generated
10
lib/api-client.js
generated
|
|
@ -40,14 +40,19 @@ var DisallowedAPIVersionReason;
|
|||
const getApiClient = function (apiDetails, { allowExternal = false } = {}) {
|
||||
const auth = (allowExternal && apiDetails.externalRepoAuth) || apiDetails.auth;
|
||||
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
|
||||
let apiURL = apiDetails.apiURL;
|
||||
if (!apiURL) {
|
||||
apiURL = deriveApiUrl(apiDetails.url);
|
||||
}
|
||||
return new retryingOctokit(githubUtils.getOctokitOptions(auth, {
|
||||
baseUrl: getApiUrl(apiDetails.url),
|
||||
baseUrl: apiURL,
|
||||
userAgent: `CodeQL-${(0, util_1.getMode)()}/${pkg.version}`,
|
||||
log: (0, console_log_level_1.default)({ level: "debug" }),
|
||||
}));
|
||||
};
|
||||
exports.getApiClient = getApiClient;
|
||||
function getApiUrl(githubUrl) {
|
||||
// Once the runner is deleted, this can also be removed since the GitHub API URL is always available in an environment variable on Actions.
|
||||
function deriveApiUrl(githubUrl) {
|
||||
const url = new URL(githubUrl);
|
||||
// If we detect this is trying to connect to github.com
|
||||
// then return with a fixed canonical URL.
|
||||
|
|
@ -62,6 +67,7 @@ function getApiDetails() {
|
|||
return {
|
||||
auth: (0, actions_util_1.getRequiredInput)("token"),
|
||||
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"),
|
||||
apiURL: (0, util_1.getRequiredEnvParam)("GITHUB_API_URL"),
|
||||
};
|
||||
}
|
||||
// Temporary function to aid in the transition to running on and off of github actions.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue