Skip to content

Commit

Permalink
Merge pull request #40 from JoinColony/update-chewie-with-new-deploym…
Browse files Browse the repository at this point in the history
…ents

Update chewie with new deployments
  • Loading branch information
area authored Jun 9, 2023
2 parents c1d0428 + b770b7e commit 195da09
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions scripts/deployments.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,60 @@ module.exports = async function(robot) {
msg.send(`Keep an eye on the build here: https://github.com/JoinColony/${repo}/actions. A notification on the outcome will also be sent to the chewie-skunkworks channel.`)
});

robot.hear(/!build (cdapp|coinmachine)-(\w+) ([0-9a-fA-F]*) (dev)?/, async msg => {
if (!isDeployer(msg.message.user.id)) return;

const appTypeRepoMapping = {
"cdapp": {
"frontend": "colonyCDapp",
"block-ingestor": "block-ingestor"
},
"coinmachine": {
"frontend": "coinMachine",
"block-ingestor": "block-ingestor-coin-machine",
"contracts": "coinMachine"
}
// Add other mappings as needed
};

const app = msg.match[1];
const type = msg.match[2];
const commitHash = msg.match[3];
const isDev = msg.match[4] ? '-dev' : '';

// Get the corresponding repository
const appMapping = appTypeRepoMapping[app];
const repo = appMapping ? appMapping[type] : undefined;

// If the repo is undefined, send a message and return
if (typeof repo === "undefined") {
msg.send(`The deployment name "${app}-${type}" is not recognized.`);
return;
}

const formData = {
'event_type': `${app}-${type}${isDev}`,
'client_payload':{
JOB: `build-${app}-${type}${isDev}-image`,
COMMIT_HASH: commitHash
}
}

await request({
method: 'POST',
uri: `https://api.github.com/repos/joinColony/${repo}/dispatches`,
keepAlive: false,
body: JSON.stringify(formData),
headers:{
"Accept": "application/vnd.github.everest-preview+json",
"Authorization": `token ${process.env.HUBOT_GITHUB_TOKEN}`,
"User-Agent": "joinColony/chewie",
}
});

msg.send(`Keep an eye on the build here: https://github.com/JoinColony/${repo}/actions. A notification on the outcome will also be sent to the chewie-skunkworks channel.`)
});

async function output(msg, res){
if (res.stdout) {
msg.send(`Stdout:
Expand Down

0 comments on commit 195da09

Please sign in to comment.