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..50be3bc 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}', @@ -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) { @@ -327,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) { @@ -341,8 +343,9 @@ async function raisePrToAllStagingBranches(context, onMergeConflict) { return createdPr }) } catch(err) { - console.log("ERROR!") console.log(err) + slack.autoSyncFailed("master"); + throw err; } } @@ -108038,7 +108041,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} /***/ }), diff --git a/handlers/pr.js b/handlers/pr.js index 43b1fc4..ac2a503 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) { @@ -135,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) { @@ -149,8 +151,9 @@ async function raisePrToAllStagingBranches(context, onMergeConflict) { return createdPr }) } catch(err) { - console.log("ERROR!") 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