Added buildCanary.js function.

This commit is contained in:
Chris 2017-11-05 13:37:35 -05:00
parent 8e576e2a3f
commit 510fd6227c
2 changed files with 28 additions and 0 deletions

View File

@ -15,5 +15,9 @@
},
"DISCORD_LOGIN_TOKEN": {
"description": "The login token of the bot."
},
"CANARY_WEBHOOK_URL": {
"required": false,
"description": "The URL for the webhook to trigger canary builds."
}
}

View File

@ -0,0 +1,24 @@
const request = require('request');
const logger = require('../logging.js');
exports.roles = ['Admins', 'Moderators'];
exports.command = function (message) {
// Read the URL endpoint from config.
var webhookUrl = process.env.CANARY_WEBHOOK_URL;
if (!webhookUrl) {
message.channel.sendMessage('Failed to start the canary build due to a missing Webhook URL.');
return;
}
// Send a POST request to the URL endpoint to trigger the build.
request.post({ url: webhookUrl, json: true, body: {
"ref": "refs/heads/master"
}}, function (error, response, body) {
if (!error && response.statusCode == 200) {
message.channel.sendMessage(`Canary build has been started.`);
} else {
logger.error(error);
message.channel.sendMessage(`Failed to start the canary build due to an error.`);
}
});
};