Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit the number of retries #111

Merged
merged 1 commit into from Jul 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/github.ts
Expand Up @@ -141,8 +141,16 @@ export const upload = async (

export const release = async (
config: Config,
releaser: Releaser
releaser: Releaser,
maxRetries: number = 3
): Promise<Release> => {
if (maxRetries <= 0) {
console.log(
`❌ Too many retries. Aborting...`
);
throw new Error("Too many retries.")
}

const [owner, repo] = config.github_repository.split("/");
const tag =
config.input_tag_name || config.github_ref.replace("refs/tags/", "");
Expand Down Expand Up @@ -227,9 +235,9 @@ export const release = async (
} catch (error) {
// presume a race with competing metrix runs
console.log(
`⚠️ GitHub release failed with status: ${error.status}, retrying...`
`⚠️ GitHub release failed with status: ${error.status}, retrying... (${maxRetries - 1} retries remaining)`
);
return release(config, releaser);
return release(config, releaser, maxRetries - 1);
}
} else {
console.log(
Expand Down