Fix retrying uploads by using Octokit retry plugin.

This commit is contained in:
Chris Gavin 2020-09-21 11:06:21 +01:00
parent e67ba57e65
commit 31c2eca167
No known key found for this signature in database
GPG key ID: 07F950B80C27E4DA
118 changed files with 19025 additions and 117 deletions

View file

@ -1,4 +1,5 @@
import * as github from "@actions/github";
import * as githubUtils from "@actions/github/lib/utils";
import * as retry from "@octokit/plugin-retry";
import consoleLogLevel from "console-log-level";
import * as path from "path";
@ -13,11 +14,14 @@ export const getApiClient = function (
if (isLocalRun() && !allowLocalRun) {
throw new Error("Invalid API call in local run");
}
return github.getOctokit(githubAuth, {
baseUrl: getApiUrl(githubUrl),
userAgent: "CodeQL Action",
log: consoleLogLevel({ level: "debug" }),
});
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
return new retryingOctokit(
githubUtils.getOctokitOptions(githubAuth, {
baseUrl: getApiUrl(githubUrl),
userAgent: "CodeQL Action",
log: consoleLogLevel({ level: "debug" }),
})
);
};
function getApiUrl(githubUrl: string): string {