Heroku sets an environment variable with the commit hash ENV['COMMIT_HASH']
.
As for the timestamp, you could hit the github api with the hash if you host your code there. Looks like the ruby-github gem can help you with this, or you could do it yourself with HTTParty.