-
Notifications
You must be signed in to change notification settings - Fork 0
DeploymentBot
Gilles Demarty edited this page May 17, 2018
·
3 revisions
-
Deployment done by Deploybot
-
We had a Bot to allow non-technical people to trigger a deploy from Basecamp Campfire.
-
This bot 🤖 was hosted on google script.
-
A payload was sent from basecamp to trigger the deployment on development (by default) or on master.
-
The bot is not very talkative right now. it just listens and acts as soon as the request is received.
-
We use deploybot as a deployment platform, to compile the hugo static website and push it to the appropriate environment.
The bot was configured to call the public address of this Google Script 👍
var environments = {
'ixd18': {
'dev': '12345',
'master': '12345',
}
};
function doPost(e) {
var data = JSON.parse(e.postData.contents);
var target_env= data['command'].split(' ',1)[0];
if (target_env !=='master') {target_env = 'dev'};
deploy(environments['ixd18'][target_env], data['creator']['name']+': '+ data['command'] );
return HtmlService.createHtmlOutput('');
}
function deploy(env_id, comment) {
var payload = {
'environment_id': env_id,
'trigger_notifications': 'true',
'comment': 'Updated from basecamp - '+ comment,
};
var options = {
'contentType': 'application/json',
'method' : 'POST',
'headers': {
'X-Api-Token': 'XXXXXXXXXXXXXXXXXXXXXXXX'
},
'payload' : JSON.stringify(payload)
};
response = UrlFetchApp.fetch('https://ixda.deploybot.com/api/v1/deployments', options);
return 0 ;
}