Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update chewie with new deployments #40

Merged
merged 4 commits into from
Jun 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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