Created
May 9, 2018 07:51
-
-
Save bulkan/089362c91ae0ff8ae723b70f0f42a94c to your computer and use it in GitHub Desktop.
show heroku ci status on anybar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { exec } = require('child_process'); | |
const anybar = require('anybar'); | |
process.stdin.resume(); | |
function exitHandler(err) { | |
if (err) { | |
console.error(err); | |
} | |
anybar('exclamation') | |
.then(process.exit); | |
} | |
[ 'exit', 'SIGINT', 'SIGUSR1', 'SIGUSR2', 'uncaughtException'].forEach(sig => process.on(sig, exitHandler)); | |
function updateStatus() { | |
console.log('checking'); | |
anybar('orange'); | |
exec('heroku ci --json --pipeline legalgateway', (err, stdout, stderr) => { | |
if (err) { | |
console.error(stdout); | |
return; | |
} | |
const build = JSON.parse(stdout)[0]; | |
console.log(`${build.commit_sha} - ${build.status}`); | |
switch (build.status) { | |
case 'building': | |
anybar('orange'); | |
break; | |
case 'running': | |
anybar('orange'); | |
break; | |
case 'failed': | |
anybar('red'); | |
break; | |
case 'errored': | |
anybar('red'); | |
break; | |
case 'succeeded': | |
anybar('green'); | |
break; | |
default: | |
anybar('exclamation'); | |
break; | |
} | |
console.log('waiting'); | |
}); | |
} | |
updateStatus(); | |
setInterval(updateStatus, 60000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment