Last active
May 22, 2019 13:58
-
-
Save kechol/d05ea6f186bb75671dbe3860db3c13cf to your computer and use it in GitHub Desktop.
Cloud function to notify labeled issue.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const request = require("request"); | |
const SLACK_WEBHOOK_URL = "https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXXXXXXXX"; | |
const LABEL_NAMES = ["bug"]; | |
exports.notifyLabelIssue = (req, res) => { | |
console.log(req.body); | |
if (req.body.action === "labeled" && req.body.issue.labels.some((l) => LABEL_NAMES.includes(l.name))) { | |
request.post({ | |
url: SLACK_WEBHOOK_URL, | |
form: "payload=" + JSON.stringify({ | |
text: req.body.issue.html_url, | |
username: "notify-label-issue", | |
icon_emoji: ":memo:", | |
unfurl_links: true, | |
}), | |
json: true, | |
}); | |
} | |
res.send(200); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "notify-label-issue", | |
"version": "0.0.1", | |
"private": true, | |
"engines": { | |
"node": ">=8" | |
}, | |
"dependencies": { | |
"request": "^2.88.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment