Reflecting Heroku push version within the app

后端 未结 9 634
故里飘歌
故里飘歌 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:52

    I had the same problem and did it through a deploy POST HTTP hook. Basically the logic is that I created a specific URL in my app and I post the new value to update the config variable.

    I did it in Python/Django, but I’m sure the same logic can be used for other languages as well:

    import heroku
    cloud = heroku.from_key(settings.HEROKU_API_KEY)
    app = cloud.apps['mycoolapp']
    latest_release = app.releases[-1]
    app.config['RELEASE'] = latest_release.name
    result['status'] = 200
    

提交回复
热议问题