mirror of
https://github.com/ow-mods/ow-mod-db.git
synced 2025-12-11 20:15:24 +01:00
cancel action if rate limit reached
This commit is contained in:
parent
841764ae88
commit
94ccc0f79f
@ -2,6 +2,8 @@ import { Octokit } from "@octokit/action";
|
||||
import { retry } from "@octokit/plugin-retry";
|
||||
import { throttling } from "@octokit/plugin-throttling";
|
||||
|
||||
export let rateLimitReached = false;
|
||||
|
||||
function createOctokit() {
|
||||
const OctokitWithPlugins = Octokit.plugin(retry, throttling);
|
||||
return new OctokitWithPlugins({
|
||||
@ -21,6 +23,11 @@ function createOctokit() {
|
||||
console.info(`Retrying after ${retryAfter} seconds!`);
|
||||
return true;
|
||||
}
|
||||
|
||||
console.warn(
|
||||
"Rate limit reached and no more retries left, set rateLimitReached flag."
|
||||
);
|
||||
rateLimitReached = true;
|
||||
},
|
||||
onAbuseLimit: (retryAfter: number, options: any) => {
|
||||
// does not retry, only logs a warning
|
||||
|
||||
@ -10,6 +10,7 @@ import { getInstallCounts } from "./get-install-counts";
|
||||
|
||||
import { writeFile } from "fs";
|
||||
import { getSettledResult } from "./promises";
|
||||
import { rateLimitReached } from "./get-octokit";
|
||||
|
||||
enum Input {
|
||||
outFile = "out-file",
|
||||
@ -103,7 +104,13 @@ async function run() {
|
||||
releases: modListWithAnalytics.filter(({ alpha }) => !alpha),
|
||||
alphaReleases: modListWithAnalytics.filter(({ alpha }) => alpha),
|
||||
});
|
||||
core.setOutput(Output.releases, databaseJson);
|
||||
|
||||
if (rateLimitReached) {
|
||||
core.setFailed("Rate limit reached");
|
||||
return;
|
||||
} else {
|
||||
core.setOutput(Output.releases, databaseJson);
|
||||
}
|
||||
|
||||
const outputFilePath = core.getInput(Input.outFile);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user