Added buildCanary.js function.
This commit is contained in:
parent
8e576e2a3f
commit
510fd6227c
4
env.json
4
env.json
|
@ -15,5 +15,9 @@
|
||||||
},
|
},
|
||||||
"DISCORD_LOGIN_TOKEN": {
|
"DISCORD_LOGIN_TOKEN": {
|
||||||
"description": "The login token of the bot."
|
"description": "The login token of the bot."
|
||||||
|
},
|
||||||
|
"CANARY_WEBHOOK_URL": {
|
||||||
|
"required": false,
|
||||||
|
"description": "The URL for the webhook to trigger canary builds."
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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.`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in New Issue