Skip to content

Commit 3a732c2

Browse files
Merge pull request #43 from chargebee/increase-protected-branch-timout
Slack notification when PR to staging branches fail
2 parents 18acd2a + f8d4e60 commit 3a732c2

4 files changed

Lines changed: 26 additions & 6 deletions

File tree

apps/github.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function resolveAllComments(context, prNumber) {
3030
)
3131

3232
for (const comment of comments) {
33-
if (comment.user.login !== 'cursor[bot]' || comment.user.login !== 'snyk-io[bot]') continue;
33+
if (comment.user.login !== 'cursor[bot]' && comment.user.login !== 'snyk-io[bot]') continue;
3434
console.log("deleting comment : " + comment.id);
3535
await context.octokit.request(
3636
'DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}',

dist/index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async function resolveAllComments(context, prNumber) {
5959
)
6060

6161
for (const comment of comments) {
62-
if (comment.user.login !== 'cursor[bot]' || comment.user.login !== 'snyk-io[bot]') continue;
62+
if (comment.user.login !== 'cursor[bot]' && comment.user.login !== 'snyk-io[bot]') continue;
6363
console.log("deleting comment : " + comment.id);
6464
await context.octokit.request(
6565
'DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}',
@@ -193,6 +193,7 @@ exports.masterBranch = masterBranch;
193193
const notifications = __nccwpck_require__(53474);
194194
const github = __nccwpck_require__(76898);
195195
const core = __nccwpck_require__(42186);
196+
const slack = __nccwpck_require__(38154);
196197
const { masterBranch } = __nccwpck_require__(51629);
197198

198199
function toPr(context) {
@@ -327,6 +328,7 @@ async function raisePrToAllStagingBranches(context, onMergeConflict) {
327328
try {
328329
let stagingBranchNames = await fetchingStagingBranchNames(context)
329330
console.log(`Raising PR to all staging branches - ${stagingBranchNames.join(", ")}`)
331+
throw new Error("Throwing a dummy error")
330332
return stagingBranchNames.map(async (branchName) => {
331333
let existingOpenPr = await github.fetchOpenPr(context, masterBranch, branchName);
332334
if (existingOpenPr) {
@@ -341,8 +343,9 @@ async function raisePrToAllStagingBranches(context, onMergeConflict) {
341343
return createdPr
342344
})
343345
} catch(err) {
344-
console.log("ERROR!")
345346
console.log(err)
347+
slack.autoSyncFailed("master");
348+
throw err;
346349
}
347350
}
348351

@@ -108038,7 +108041,14 @@ async function notifyPrMergeFailed(pr) {
108038108041
slack.markdown(`Team <!here>, fix it by merging <${pr.url}|this PR> *manually*.`)
108039108042
])
108040108043
}
108041-
module.exports = {notifyNewPR, notifyMergedPR, notifyClosedPR, notifyPrHasConflicts, notifyPrMergeFailed}
108044+
108045+
async function autoSyncFailed(channelName) {
108046+
let textMessage = `AUTO SYNC FAILED`
108047+
await slack.sendMessage(channelName, textMessage, [
108048+
slack.header(":need_action: AUTO SYNC FAILED :need_action:")
108049+
])
108050+
}
108051+
module.exports = {notifyNewPR, notifyMergedPR, notifyClosedPR, notifyPrHasConflicts, notifyPrMergeFailed, autoSyncFailed}
108042108052

108043108053
/***/ }),
108044108054

handlers/pr.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const notifications = require("./../notifications/pr");
22
const github = require("./../apps/github");
33
const core = require('@actions/core');
4+
const slack = require("../notifications/slack");
45
const { masterBranch } = require("../constants");
56

67
function toPr(context) {
@@ -135,6 +136,7 @@ async function raisePrToAllStagingBranches(context, onMergeConflict) {
135136
try {
136137
let stagingBranchNames = await fetchingStagingBranchNames(context)
137138
console.log(`Raising PR to all staging branches - ${stagingBranchNames.join(", ")}`)
139+
throw new Error("Throwing a dummy error")
138140
return stagingBranchNames.map(async (branchName) => {
139141
let existingOpenPr = await github.fetchOpenPr(context, masterBranch, branchName);
140142
if (existingOpenPr) {
@@ -149,8 +151,9 @@ async function raisePrToAllStagingBranches(context, onMergeConflict) {
149151
return createdPr
150152
})
151153
} catch(err) {
152-
console.log("ERROR!")
153154
console.log(err)
155+
slack.autoSyncFailed("master");
156+
throw err;
154157
}
155158
}
156159

notifications/slack.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,11 @@ async function notifyPrMergeFailed(pr) {
108108
slack.markdown(`Team <!here>, fix it by merging <${pr.url}|this PR> *manually*.`)
109109
])
110110
}
111-
module.exports = {notifyNewPR, notifyMergedPR, notifyClosedPR, notifyPrHasConflicts, notifyPrMergeFailed}
111+
112+
async function autoSyncFailed(channelName) {
113+
let textMessage = `AUTO SYNC FAILED`
114+
await slack.sendMessage(channelName, textMessage, [
115+
slack.header(":need_action: AUTO SYNC FAILED :need_action:")
116+
])
117+
}
118+
module.exports = {notifyNewPR, notifyMergedPR, notifyClosedPR, notifyPrHasConflicts, notifyPrMergeFailed, autoSyncFailed}

0 commit comments

Comments
 (0)