-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display link to current git commit deployed #117
Comments
Another possible option to consider is just using JavaScript to call the GitHub API for the repo, although this assumes continuous deployment. |
Hi @robwise, the best way to do this is to set an env var as part of a deployment script. ```#!/bin/bash
# Pass in app as either staging or production first -- must match what you seen in git remote -v
# Examples:
# ./deploy staging
# ./deploy staging --force
# ./deploy production
app=$1
shift
sha=`git rev-parse HEAD 2>/dev/null`
current_branch=`git symbolic-ref HEAD 2> /dev/null | sed -e 's/refs\/heads\///'`
# echo "current_branch is $current_branch"
# echo "sha is $sha"
# echo "app is $app"
if [ "$app" == "" ]; then
echo "You must specify a param value for the app, such as production or staging"
exit 1
fi
if [[ "$app" == "production" && "$current_branch" != "master" ]]; then
echo "You can only deploy master to production!"
exit 1
fi
echo Running:
echo git push $app $current_branch:master $@
git push $app $current_branch:master $@
echo Setting heroku config DEPLOYMENT_SHA
echo heroku config:set DEPLOYMENT_SHA=$sha --remote $app
heroku config:set DEPLOYMENT_SHA=$sha --remote $app
# Run migrations always just in case
heroku run rake db:migrate --remote $app
heroku restart --remote $app And then add this to def self.current_sha
@sha ||= if ENV["DEPLOYMENT_SHA"].present?
puts "Set SHA to #{ENV['DEPLOYMENT_SHA']}"
ENV["DEPLOYMENT_SHA"]
else
`git rev-parse HEAD 2>/dev/null`.to_s.strip
end
end And then have this in the view: Deployed Git Commit: <%= RailsReactTutorial.current_sha %> |
Work in progress: #125 |
Boom! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Let's display a link to the current git commit deployed on Heroku.
There's a number of options here:
http://stackoverflow.com/questions/14583282/heroku-display-hash-of-current-commit
The text was updated successfully, but these errors were encountered: