forked from mirrors/action-gh-release
reintroduce octokit retry and throttling plugins
This commit is contained in:
parent
44946dc88f
commit
040bca2f2d
5 changed files with 494 additions and 87 deletions
28
src/main.ts
28
src/main.ts
|
@ -3,13 +3,13 @@ import {
|
|||
parseConfig,
|
||||
isTag,
|
||||
unmatchedPatterns,
|
||||
uploadUrl
|
||||
uploadUrl,
|
||||
} from "./util";
|
||||
import { release, upload, GitHubReleaser } from "./github";
|
||||
import { getOctokit } from "@actions/github";
|
||||
import { Octokit } from "@octokit/action";
|
||||
import { setFailed, setOutput } from "@actions/core";
|
||||
import { GitHub, getOctokitOptions } from "@actions/github/lib/utils";
|
||||
|
||||
import { retry } from "@octokit/plugin-retry";
|
||||
import { throttling } from "@octokit/plugin-throttling";
|
||||
import { env } from "process";
|
||||
|
||||
async function run() {
|
||||
|
@ -24,7 +24,7 @@ async function run() {
|
|||
}
|
||||
if (config.input_files) {
|
||||
const patterns = unmatchedPatterns(config.input_files);
|
||||
patterns.forEach(pattern =>
|
||||
patterns.forEach((pattern) =>
|
||||
console.warn(`🤔 Pattern '${pattern}' does not match any files.`)
|
||||
);
|
||||
if (patterns.length > 0 && config.input_fail_on_unmatched_files) {
|
||||
|
@ -32,13 +32,9 @@ async function run() {
|
|||
}
|
||||
}
|
||||
|
||||
// const oktokit = GitHub.plugin(
|
||||
// require("@octokit/plugin-throttling"),
|
||||
// require("@octokit/plugin-retry")
|
||||
// );
|
||||
|
||||
const gh = getOctokit(config.github_token, {
|
||||
//new oktokit(
|
||||
const OctokitWithPlugins = Octokit.plugin(retry, throttling);
|
||||
const gh = new OctokitWithPlugins({
|
||||
auth: config.github_token,
|
||||
throttle: {
|
||||
onRateLimit: (retryAfter, options) => {
|
||||
console.warn(
|
||||
|
@ -55,8 +51,8 @@ async function run() {
|
|||
console.warn(
|
||||
`Abuse detected for request ${options.method} ${options.url}`
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
//);
|
||||
const rel = await release(config, new GitHubReleaser(gh));
|
||||
|
@ -67,7 +63,7 @@ async function run() {
|
|||
}
|
||||
const currentAssets = rel.assets;
|
||||
const assets = await Promise.all(
|
||||
files.map(async path => {
|
||||
files.map(async (path) => {
|
||||
const json = await upload(
|
||||
config,
|
||||
gh,
|
||||
|
@ -78,7 +74,7 @@ async function run() {
|
|||
delete json.uploader;
|
||||
return json;
|
||||
})
|
||||
).catch(error => {
|
||||
).catch((error) => {
|
||||
throw error;
|
||||
});
|
||||
setOutput("assets", assets);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue