Reflecting Heroku push version within the app

后端 未结 9 811
故里飘歌
故里飘歌 2021-01-30 09:17

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

9条回答
  •  感动是毒
    2021-01-30 09:50

    After every push, run (assuming a bash shell):

    heroku config:add rel=$(heroku releases | tail -2 | awk '{print $1}')
    

    You can then just access the rel environment variable from your app.

    Alternatively, if you'd like to present the date of the push, which, IMO, represents more meaningful information:

    heroku config:add rel=$(heroku releases | tail -2 | awk '{print $5,$6,$7}')
    

    Or, my favorite, which contains date and version with no whitespace:

    heroku config:add rel=$(heroku releases | tail -2 | awk '{print $5"t"$6$7"."$1}')
    

提交回复
热议问题