Skip to content

Commit e214155

Browse files
committed
Add more Graph deployments to chewie
1 parent 1216477 commit e214155

File tree

2 files changed

+38
-17
lines changed

2 files changed

+38
-17
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"node": "0.10.x"
4343
},
4444
"devDependencies": {
45+
"eslint": "^7.20.0",
4546
"prettier": "^1.13.7"
4647
}
4748
}

scripts/deployments.js

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,26 @@ module.exports = async function(robot) {
283283
await output(msg, res);
284284
});
285285

286+
const triggerGraphDeployment = async function(event_type, commit){
287+
const formData = {
288+
'event_type': event_type,
289+
'client_payload':{
290+
FRONTEND_COMMIT: commit
291+
}
292+
}
293+
return request({
294+
method: 'POST',
295+
uri: `https://api.github.com/repos/joinColony/subgraph/dispatches`,
296+
keepAlive: false,
297+
body: JSON.stringify(formData),
298+
headers:{
299+
"Accept": "application/vnd.github.everest-preview+json",
300+
"Authorization": `token ${process.env.HUBOT_GITHUB_TOKEN}`,
301+
"User-Agent": "JoinColony/chewie",
302+
}
303+
});
304+
}
305+
286306
const toQARegex = /^!deploy qa network ([0-9]*) (backend|frontend) ([0-9a-fA-f]*)( dev)?$/
287307
robot.hear(toQARegex, async msg => {
288308
const { brain } = robot;
@@ -319,24 +339,11 @@ module.exports = async function(robot) {
319339
try {
320340
if (location === 'frontend') {
321341
if (networkId === "5"){
322-
const formData = {
323-
'event_type': `trigger-deploy-goerli`,
324-
'client_payload':{
325-
FRONTEND_COMMIT: commit
326-
}
327-
}
328-
await request({
329-
method: 'POST',
330-
uri: `https://api.github.com/repos/joinColony/subgraph/dispatches`,
331-
keepAlive: false,
332-
body: JSON.stringify(formData),
333-
headers:{
334-
"Accept": "application/vnd.github.everest-preview+json",
335-
"Authorization": `token ${process.env.HUBOT_GITHUB_TOKEN}`,
336-
"User-Agent": "JoinColony/chewie",
337-
}
338-
});
342+
await triggerGraphDeployment('trigger-deploy-goerli', commit);
339343
msg.send("Keep an eye on the deployment of the graph here: <https://github.com/joinColony/subgraph/actions> and the status of the graph itself (which will require time to sync after deployment) here: <https://thegraph.com/explorer/subgraph/joincolony/colony-goerli>")
344+
} else if (networkId === "100") {
345+
await triggerGraphDeployment('trigger-deploy-xdai-qa', commit)
346+
msg.send("Keep an eye on the deployment of the graph here: <https://github.com/joinColony/subgraph/actions> and the status of the graph itself (which will require time to sync after deployment) here: <https://thegraph.com/explorer/subgraph/joincolony/colony-xdai-qa>")
340347
} else {
341348
msg.send("I don't know how to deploy the graph for that network. Someone needs to teach this old wookie some new tricks!")
342349
}
@@ -425,6 +432,19 @@ module.exports = async function(robot) {
425432
res = err;
426433
}
427434
await output(msg, res);
435+
// Get the commit being used from the image tag
436+
res = await exec(`kubectl get deployment dapp-red-network-$FROM_NETWORK_ID -o yaml | grep image: | awk '{print $2}' | cut -d ":" -f2 | tr -d '\n'`)
437+
const commit = res.stdout
438+
if (toNetworkId === "5"){
439+
await triggerGraphDeployment('trigger-deploy-goerli', commit);
440+
msg.send("Keep an eye on the deployment of the graph here: <https://github.com/joinColony/subgraph/actions> and the status of the graph itself (which will require time to sync after deployment) here: <https://thegraph.com/explorer/subgraph/joincolony/colony-goerli>")
441+
} else if (toNetworkId === "100") {
442+
await triggerGraphDeployment('trigger-deploy-xdai', commit)
443+
msg.send("Keep an eye on the deployment of the graph here: <https://github.com/joinColony/subgraph/actions> and the status of the graph itself (which will require time to sync after deployment) here: <https://thegraph.com/explorer/subgraph/joincolony/colony-xdai>")
444+
445+
} else {
446+
msg.send("I don't know how to deploy the graph for that network. Someone needs to teach this old wookie some new tricks!")
447+
}
428448
})
429449

430450
// const toProductionRegex = /^!deploy production network ([0-9]*)$/

0 commit comments

Comments
 (0)