Treat Heroku just like any remote Git repository, you can use git ls-remote :
git ls-remote heroku
( heroku here is the remote name)
UPDATE:
Since the OP actually wants to get SHA in Ruby env, one possible way would be to use custom buildpack .
To get started, go to Heroku Ruby Buildpack and unlock it so you can create your own options. Now clone the fork and take a look at lib/language_pack/ruby.rb Add a new method, for example:
def get_SHA
How you are going to receive SHA is up to you. You can execute the git command and use the return value:
git log -1 --format="%H"
Or you can use the @avaynshtok tip and use Heroku pearls to use the releases method.
Then, as soon as you have a SHA, install it as ENV var.
Then find the compile method in ruby.rb and add the get_sha method at the end of it:
def compile Dir.chdir(build_path) install_ruby setup_language_pack_environment allow_git do install_language_pack_gems build_bundler create_database_yml install_binaries run_assets_precompile_rake_task get_sha
Revert your changes back to GitHub and now go to the command line. You need to add a new var configuration to your Heroku application:
heroku config:add BUILDPACK_URL= git@github.com :<your GitHub username>/heroku-buildpack-ruby.git
Note that you need to make sure that you replace <your GitHub username> with ... well, <your GitHub username> , so you point to a forked repo.
Finally, run one last command that allows the Heroku labs function , which allows the slug compiler to access custom vars:
heroku labs:enable user_env_compile
You should now be tuned. So what is happening now? Well, when you click on Heroku, Heroku will get the changes, and then you will see that you have your own set of url buildpack. This way it will retrieve your own buildpack from GitHub and then use it to create the bullet. This means that after all default compilation commands have been executed, this will end with the get_sha method, which should set ENV var SHA to the corresponding SHA. You should now have access to this ENV var from Ruby to do what you will.