Skip to content

Commit b8d6d13

Browse files
vdicejeremyrickard
authored andcommitted
ci(brigade.js): add issue comment handler (#45)
1 parent 43202d0 commit b8d6d13

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

brigade.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,26 @@ function runTests(e, p) {
5555
return notificationWrap(build(e, p), note)
5656
}
5757

58+
// handleIssueComment handles an issue_comment event, parsing the comment
59+
// text and determining whether or not to trigger a corresponding action
60+
function handleIssueComment(e, p) {
61+
if (e.payload) {
62+
payload = JSON.parse(e.payload);
63+
64+
// Extract the comment body and trim whitespace
65+
comment = payload.body.comment.body.trim();
66+
67+
// Here we determine if a comment should provoke an action
68+
switch(comment) {
69+
case "/brig run":
70+
return runTests(e, p);
71+
break;
72+
default:
73+
console.log(`No applicable action found for comment: ${comment}`);
74+
}
75+
}
76+
}
77+
5878
// A GitHub Check Suite notification
5979
class Notification {
6080
constructor(name, e, p) {
@@ -78,7 +98,7 @@ class Notification {
7898
// Send a new notification, and return a Promise<result>.
7999
run() {
80100
this.count++
81-
var j = new Job(`${this.name}-${this.count}`, "deis/brigade-github-check-run:latest");
101+
var j = new Job(`${this.name}-${this.count}`, "brigadecore/brigade-github-check-run:v0.1.0");
82102
j.imageForcePull = true;
83103
j.env = {
84104
CHECK_CONCLUSION: this.conclusion,
@@ -130,3 +150,5 @@ events.on("exec", (e, p) => {
130150
events.on("check_suite:requested", runSuite)
131151
events.on("check_suite:rerequested", runSuite)
132152
events.on("check_run:rerequested", runSuite)
153+
events.on("issue_comment:created", handleIssueComment);
154+
events.on("issue_comment:edited", handleIssueComment);

0 commit comments

Comments
 (0)