0

How to actually get hash of the latest commit deployed to Heroku in 2022?


Yes, this is a duplicate of a lot of other SO questions. But neither of them worked for me.

  1. Access current git commit number from within Heroku app
    • SOURCE_VERSION property does not exist on process.env (not even undefined);
    • logging the whole process.env object, I couldn't find any environment variable that would contain anything remotely relevant;
    • /etc/heroku/dyno file does not exist on runtime;
  2. Heroku - Display hash of current commit in browser
    • heroku config doesn't show anything relevant;
    • heroku labs:enable runtime-dyno-metadata – Heroku Labs is not supported for Heroku Review Apps, which I am a heavy user of;
    • post-commit hook seems too hacky, I'm considering this approach as a last resort;

Similar to using post-commit hook, I could use available values of process.env.npm_package_repository_url, and process.env.HEROKU_PR_NUMBER to fetch the latest commit hash through an HTTP call. Similarly, I'm considering this approach as a last resort.

Parzh from Ukraine
  • 7,999
  • 3
  • 34
  • 65

0 Answers0