Last active
August 29, 2015 14:11
-
-
Save joeartsea/63a577e867c72711f735 to your computer and use it in GitHub Desktop.
Using Heroku Platform API
This file contains 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
var appName, | |
Heroku = require('heroku-client'), | |
heroku = new Heroku({ token: process.env.HEROKU_API_TOKEN }); | |
heroku.apps().create().then(function (app) { | |
appName = app.name; | |
return heroku.apps(appName).addons().create({ | |
"plan": "mongolab" | |
}); | |
}).then(function (addon) { | |
return heroku.apps(appName).dynos().create({ | |
"attach": true, | |
"command": "bash" | |
}); | |
}).then(function (dyno) { | |
return heroku.apps(appName).builds().create({ | |
"source_blob": { | |
"url": "https://github.com/node-red/node-red/tarball/master/" | |
} | |
}); | |
}).then(function (build) { | |
var intervalId = setInterval(function() { | |
heroku.apps(appName).builds(build.id).result().info().then(function (result) { | |
console.log(result.build.status); | |
if (result.build.status == 'succeeded') { | |
clearInterval(intervalId); | |
} | |
}); | |
}, 3000); | |
}).catch(function (e) { | |
console.error(e.stack); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment