Skip to content

Instantly share code, notes, and snippets.

@feixionglee
Last active December 29, 2015 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feixionglee/7714375 to your computer and use it in GitHub Desktop.
Save feixionglee/7714375 to your computer and use it in GitHub Desktop.
deployment version track
use the following code in a Rails initializer
if Rails.env.production?
commit_hash = `git rev-parse HEAD 2>/dev/null`.to_s.strip
APP_VERSION = Time.now.utc.strftime("%Y%m%d-%H%M-") + commit_hash[-8..-1]
else
APP_VERSION = Time.now.utc.strftime("%Y%m%d-%H%M-development")
end
layout:
<meta name="app-version" content="<%= APP_VERSION %>">
[source blog link](http://blog.lingohub.com/developers/2013/04/use-git-commit-sha-to-keep-track-of-running-version-in-production/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment