Reflecting Heroku push version within the app

后端 未结 9 636
故里飘歌
故里飘歌 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 10:04

    Following @jassa answer - but using the more recent PlatformAPI

    if (app_name = ENV["HEROKU_APP_NAME"]).present? and ENV['HEROKU_API_KEY'].present?
      require 'platform-api'
      heroku = PlatformAPI.connect(ENV['HEROKU_API_KEY'], default_headers: {'Range' => 'version ..; order=desc'})
      released_at_s = heroku.app.info(app_name)['released_at']
      released_at_d = Time.parse(released_at_s).strftime('%Y-%m-%d')
      release = heroku.release.list(app_name).first
      deploy_v = release['description']
      version = release['version']
      ENV['HEROKU_RELEASE_NAME'] = "#{version} (#{deploy_v}) #{released_at_d}"
    end
    

提交回复
热议问题