Skip to content

Instantly share code, notes, and snippets.

@joeartsea
Last active August 29, 2015 14:11
Show Gist options
  • Save joeartsea/63a577e867c72711f735 to your computer and use it in GitHub Desktop.
Save joeartsea/63a577e867c72711f735 to your computer and use it in GitHub Desktop.
Using Heroku Platform API
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