From f3ef5a662153a77b1fa8ad2458b3febe7aa94ccd Mon Sep 17 00:00:00 2001 From: Rasmus Hedlund Rosted <68533799+Rasmus-Rosted@users.noreply.github.com> Date: Thu, 21 Jan 2021 15:18:57 +0100 Subject: [PATCH 1/8] Warning instead of error when branch is not found --- main.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main.js b/main.js index ec622d2..44b1cd6 100644 --- a/main.js +++ b/main.js @@ -36,11 +36,15 @@ async function main() { console.log("==> Deleting \"" + ownerOfRepository + "/" + repositoryContainingBranches + "/" + branch + "\" branch") - await client.git.deleteRef({ - owner: ownerOfRepository, - repo: repositoryContainingBranches, - ref: "heads/" + branch - }) + try { + await client.git.deleteRef({ + owner: ownerOfRepository, + repo: repositoryContainingBranches, + ref: "heads/" + branch + }) + } catch (error) { + core.warning(error.message) + } } } catch (error) { core.setFailed(error.message) From 2250e0acda70a12445b6a2e19fd45eb5182b76b3 Mon Sep 17 00:00:00 2001 From: Rasmus Hedlund Rosted <68533799+Rasmus-Rosted@users.noreply.github.com> Date: Thu, 21 Jan 2021 15:34:26 +0100 Subject: [PATCH 2/8] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0a24b01..14a7294 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ An action that deletes multiple branches from repository. Optionally one can provide a `prefix` or `suffix` strings that would be appended or prepended to every branch name. If it is needed to specify which owner and repository the branches are located in, then the `owner` and `repository` can be provided as well. +If a branch is not found, a warning will be written to the console, and the action will continue. ## Usage From a01558723801b54c679bc81359eaace5f25fcc66 Mon Sep 17 00:00:00 2001 From: Rasmus Hedlund Rosted <68533799+Rasmus-Rosted@users.noreply.github.com> Date: Fri, 22 Jan 2021 10:07:21 +0100 Subject: [PATCH 3/8] Update action.yml soft_fail parameter in action.yml --- action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/action.yml b/action.yml index 094b1ae..e3dd091 100644 --- a/action.yml +++ b/action.yml @@ -27,6 +27,10 @@ inputs: suffix: description: Additional suffix to append to every branch name required: false + soft_fail: + description: If set to `true` the workflow will continue if a branch reference is not found + required: false + default: false runs: using: node12 main: main.js From c83c4009579801b33fbb18ea0e873dab44058e97 Mon Sep 17 00:00:00 2001 From: Rasmus Hedlund Rosted <68533799+Rasmus-Rosted@users.noreply.github.com> Date: Fri, 22 Jan 2021 10:11:56 +0100 Subject: [PATCH 4/8] Update main.js soft_fail flag --- main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 44b1cd6..83b7953 100644 --- a/main.js +++ b/main.js @@ -10,6 +10,7 @@ async function main() { const branches = core.getInput("branches") const prefix = core.getInput("prefix") const suffix = core.getInput("suffix") + const shouldFailSoftly = core.getInput("soft_fail") const client = github.getOctokit(token) @@ -43,7 +44,10 @@ async function main() { ref: "heads/" + branch }) } catch (error) { - core.warning(error.message) + if(shouldFailSoftly) + core.warning(error.message) + else + core.setFailed(error.message) } } } catch (error) { From 05906501dd30af3d96924e72541c2ad7d301ad7a Mon Sep 17 00:00:00 2001 From: Rasmus Hedlund Rosted <68533799+Rasmus-Rosted@users.noreply.github.com> Date: Fri, 22 Jan 2021 10:14:33 +0100 Subject: [PATCH 5/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 14a7294..a636773 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ An action that deletes multiple branches from repository. Optionally one can provide a `prefix` or `suffix` strings that would be appended or prepended to every branch name. If it is needed to specify which owner and repository the branches are located in, then the `owner` and `repository` can be provided as well. -If a branch is not found, a warning will be written to the console, and the action will continue. +If setting the `soft_fail` flag to `true` a warning will be written to the console, and the action will continue, instead of the the action failing. The default is `false`. ## Usage From eb3f94bab5e1b33e8b6821cd05769b7ffc443f38 Mon Sep 17 00:00:00 2001 From: Rasmus Hedlund Rosted <68533799+Rasmus-Rosted@users.noreply.github.com> Date: Fri, 22 Jan 2021 10:24:25 +0100 Subject: [PATCH 6/8] Update main.js --- main.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 83b7953..89fb324 100644 --- a/main.js +++ b/main.js @@ -10,7 +10,7 @@ async function main() { const branches = core.getInput("branches") const prefix = core.getInput("prefix") const suffix = core.getInput("suffix") - const shouldFailSoftly = core.getInput("soft_fail") + const soft_fail = core.getInput("soft_fail") const client = github.getOctokit(token) @@ -44,7 +44,9 @@ async function main() { ref: "heads/" + branch }) } catch (error) { - if(shouldFailSoftly) + const shouldFailSoftly = (soft_fail === 'true'); + + if(shouldFailSoftly === ) core.warning(error.message) else core.setFailed(error.message) From 02549921959816b0d6a31bc8eecdeac7d4b41a1a Mon Sep 17 00:00:00 2001 From: Rasmus Hedlund Rosted <68533799+Rasmus-Rosted@users.noreply.github.com> Date: Fri, 22 Jan 2021 10:25:54 +0100 Subject: [PATCH 7/8] Update main.js --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 89fb324..177979f 100644 --- a/main.js +++ b/main.js @@ -46,7 +46,7 @@ async function main() { } catch (error) { const shouldFailSoftly = (soft_fail === 'true'); - if(shouldFailSoftly === ) + if(shouldFailSoftly) core.warning(error.message) else core.setFailed(error.message) From 85f1eda72c468c5b08010f08124adb09d04c17df Mon Sep 17 00:00:00 2001 From: Rasmus Hedlund Rosted <68533799+Rasmus-Rosted@users.noreply.github.com> Date: Fri, 22 Jan 2021 10:45:24 +0100 Subject: [PATCH 8/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a636773..f7a6517 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ An action that deletes multiple branches from repository. Optionally one can provide a `prefix` or `suffix` strings that would be appended or prepended to every branch name. If it is needed to specify which owner and repository the branches are located in, then the `owner` and `repository` can be provided as well. -If setting the `soft_fail` flag to `true` a warning will be written to the console, and the action will continue, instead of the the action failing. The default is `false`. +If setting the `soft_fail` flag to `true` a warning will be written to the console, and the action will continue, instead of the action failing. The default is `false`. ## Usage