Last active
December 7, 2015 02:46
-
-
Save digidigo/5808f862740d80207cee to your computer and use it in GitHub Desktop.
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
// I couldn't find a github integration for slack or IFTTT that supported | |
// GitHub releases. And I really didn't want to maintain a server or heroku. | |
// Enter Parse --- I can think of lots of other use cases for something like this. | |
Parse.Cloud.define("release_to_slack", function(request, response) { | |
var release = request.params.release; | |
var author = release.author.login; | |
var name = release.name; | |
var tag_name = release.tag_name; | |
var description = release.body; | |
console.log("Author: " + author); | |
console.log("Name: " + name); | |
console.log("Tag Name: " + tag_name); | |
console.log("Description: " + description); | |
var text = " @" + author + " just created release " + name + " tagged: ( " + tag_name + " ) and is preparing to deploy to production. \n Description: \n " + description; | |
Parse.Cloud.httpRequest({ | |
url: "https://hooks.slack.com/services/XXXXXXXX/XXXXXXX/XXXXXXXX", | |
method: 'POST', | |
header:{ | |
}, | |
body:'payload={"channel": "#releases", "username": "hook2parse2slack", "icon_emoji": ":tada:", "text": "' + text + ' "}', | |
success: function (httpResponse) { | |
console.log(httpResponse.text); | |
response.success(httpResponse); | |
}, | |
error:function (httpResponse) { | |
console.error('Request failed with response code ' + httpResponse.status); | |
response.error(httpResponse.status); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment