Every time I push my app to heroku I see the line
-----> Launching... done, v43
Is there a way to make that version number apear within the
In Node.js using JavaScript fetch
(and the forthcoming async/await), you can do it with the following code (no push hooks!):
const fetch = require('node-fetch');
const url = 'https://api.heroku.com/apps/myapp/releases';
const headers = {
Accept: 'application/vnd.heroku+json; version=3',
Authorization: 'Basic '+base64Encode(':'+process.env.HEROKU_API_TOKEN)
};
const response = await fetch(url, { headers });
const releases = await response.json();
const lastRelease = releases[releases.length-1];
const version = lastRelease.version;
const created = lastRelease.created_at;
using
function base64Encode(str) {
return new Buffer(str, 'binary').toString('base64');
}
Note this requires
$ heroku config:set HEROKU_API_TOKEN=\`heroku auth:token`.
See devcenter.heroku.com/articles/platform-api-reference#release-list.