From 04c14f526b60cdbb1aca8e0333561e4aa7d77aae Mon Sep 17 00:00:00 2001 From: Raz Halaly Date: Sun, 18 Jul 2021 02:24:12 +0300 Subject: [PATCH] Update github.ts (#111) --- src/github.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/github.ts b/src/github.ts index 2613d4c32..164e07a9c 100644 --- a/src/github.ts +++ b/src/github.ts @@ -141,8 +141,16 @@ export const upload = async ( export const release = async ( config: Config, - releaser: Releaser + releaser: Releaser, + maxRetries: number = 3 ): Promise => { + 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/", ""); @@ -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(