From 87d448ff5a3a14366fe2ee94cb4264c3ea1faa30 Mon Sep 17 00:00:00 2001 From: Jarun Madhesh Date: Fri, 9 Jan 2026 13:09:56 +0530 Subject: [PATCH 1/4] Throw error when PR to staging branches fail Signed-off-by: Jarun Madhesh --- apps/github.js | 2 +- dist/index.js | 4 ++-- handlers/pr.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/github.js b/apps/github.js index d3027d5..7fb049d 100644 --- a/apps/github.js +++ b/apps/github.js @@ -30,7 +30,7 @@ async function resolveAllComments(context, prNumber) { ) for (const comment of comments) { - if (comment.user.login !== 'cursor[bot]' || comment.user.login !== 'snyk-io[bot]') continue; + if (comment.user.login !== 'cursor[bot]' && comment.user.login !== 'snyk-io[bot]') continue; console.log("deleting comment : " + comment.id); await context.octokit.request( 'DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}', diff --git a/dist/index.js b/dist/index.js index a728e48..55360b6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -59,7 +59,7 @@ async function resolveAllComments(context, prNumber) { ) for (const comment of comments) { - if (comment.user.login !== 'cursor[bot]' || comment.user.login !== 'snyk-io[bot]') continue; + if (comment.user.login !== 'cursor[bot]' && comment.user.login !== 'snyk-io[bot]') continue; console.log("deleting comment : " + comment.id); await context.octokit.request( 'DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}', @@ -341,8 +341,8 @@ async function raisePrToAllStagingBranches(context, onMergeConflict) { return createdPr }) } catch(err) { - console.log("ERROR!") console.log(err) + throw err; } } diff --git a/handlers/pr.js b/handlers/pr.js index 43b1fc4..433e614 100644 --- a/handlers/pr.js +++ b/handlers/pr.js @@ -149,8 +149,8 @@ async function raisePrToAllStagingBranches(context, onMergeConflict) { return createdPr }) } catch(err) { - console.log("ERROR!") console.log(err) + throw err; } } From bad203f9165e8f0c02a940510202567ee39e8dcc Mon Sep 17 00:00:00 2001 From: Jarun Madhesh Date: Fri, 9 Jan 2026 16:37:47 +0530 Subject: [PATCH 2/4] Send slack notification on any error Signed-off-by: Jarun Madhesh --- handlers/pr.js | 2 ++ notifications/slack.js | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/handlers/pr.js b/handlers/pr.js index 433e614..8bc30d3 100644 --- a/handlers/pr.js +++ b/handlers/pr.js @@ -1,6 +1,7 @@ const notifications = require("./../notifications/pr"); const github = require("./../apps/github"); const core = require('@actions/core'); +const slack = require("../notifications/slack"); const { masterBranch } = require("../constants"); function toPr(context) { @@ -150,6 +151,7 @@ async function raisePrToAllStagingBranches(context, onMergeConflict) { }) } catch(err) { console.log(err) + slack.autoSyncFailed("master"); throw err; } } diff --git a/notifications/slack.js b/notifications/slack.js index 92cc4b4..3a7060a 100644 --- a/notifications/slack.js +++ b/notifications/slack.js @@ -108,4 +108,11 @@ async function notifyPrMergeFailed(pr) { slack.markdown(`Team , fix it by merging <${pr.url}|this PR> *manually*.`) ]) } -module.exports = {notifyNewPR, notifyMergedPR, notifyClosedPR, notifyPrHasConflicts, notifyPrMergeFailed} \ No newline at end of file + +async function autoSyncFailed(channelName) { + let textMessage = `AUTO SYNC FAILED` + await slack.sendMessage(channelName, textMessage, [ + slack.header(":need_action: AUTO SYNC FAILED :need_action:") + ]) +} +module.exports = {notifyNewPR, notifyMergedPR, notifyClosedPR, notifyPrHasConflicts, notifyPrMergeFailed, autoSyncFailed} \ No newline at end of file From c48cfb5f1d9644ba047909f19de9a4b25f242aeb Mon Sep 17 00:00:00 2001 From: Jarun Madhesh Date: Fri, 9 Jan 2026 16:42:36 +0530 Subject: [PATCH 3/4] build Signed-off-by: Jarun Madhesh --- dist/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index 55360b6..6e7cb4c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -193,6 +193,7 @@ exports.masterBranch = masterBranch; const notifications = __nccwpck_require__(53474); const github = __nccwpck_require__(76898); const core = __nccwpck_require__(42186); +const slack = __nccwpck_require__(38154); const { masterBranch } = __nccwpck_require__(51629); function toPr(context) { @@ -342,6 +343,7 @@ async function raisePrToAllStagingBranches(context, onMergeConflict) { }) } catch(err) { console.log(err) + slack.autoSyncFailed("master"); throw err; } } @@ -108038,7 +108040,14 @@ async function notifyPrMergeFailed(pr) { slack.markdown(`Team , fix it by merging <${pr.url}|this PR> *manually*.`) ]) } -module.exports = {notifyNewPR, notifyMergedPR, notifyClosedPR, notifyPrHasConflicts, notifyPrMergeFailed} + +async function autoSyncFailed(channelName) { + let textMessage = `AUTO SYNC FAILED` + await slack.sendMessage(channelName, textMessage, [ + slack.header(":need_action: AUTO SYNC FAILED :need_action:") + ]) +} +module.exports = {notifyNewPR, notifyMergedPR, notifyClosedPR, notifyPrHasConflicts, notifyPrMergeFailed, autoSyncFailed} /***/ }), From f8d4e6095e1c43a7ca33cb7dbe5d416056c6eeaa Mon Sep 17 00:00:00 2001 From: Jarun Madhesh Date: Fri, 9 Jan 2026 17:23:28 +0530 Subject: [PATCH 4/4] Throw error to test Signed-off-by: Jarun Madhesh --- dist/index.js | 1 + handlers/pr.js | 1 + 2 files changed, 2 insertions(+) diff --git a/dist/index.js b/dist/index.js index 6e7cb4c..50be3bc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -328,6 +328,7 @@ async function raisePrToAllStagingBranches(context, onMergeConflict) { try { let stagingBranchNames = await fetchingStagingBranchNames(context) console.log(`Raising PR to all staging branches - ${stagingBranchNames.join(", ")}`) + throw new Error("Throwing a dummy error") return stagingBranchNames.map(async (branchName) => { let existingOpenPr = await github.fetchOpenPr(context, masterBranch, branchName); if (existingOpenPr) { diff --git a/handlers/pr.js b/handlers/pr.js index 8bc30d3..ac2a503 100644 --- a/handlers/pr.js +++ b/handlers/pr.js @@ -136,6 +136,7 @@ async function raisePrToAllStagingBranches(context, onMergeConflict) { try { let stagingBranchNames = await fetchingStagingBranchNames(context) console.log(`Raising PR to all staging branches - ${stagingBranchNames.join(", ")}`) + throw new Error("Throwing a dummy error") return stagingBranchNames.map(async (branchName) => { let existingOpenPr = await github.fetchOpenPr(context, masterBranch, branchName); if (existingOpenPr) {