Heroku - Display hash of current commit in browser

前端 未结 9 1602
逝去的感伤
逝去的感伤 2020-12-02 14:45

I want to display the hash of the current git commit in the browser so that testing team (which does not have an access to run heruko commands) will be able to include the c

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 14:47

    Both culix and joshwa have great answers. If you name your heroku git remotes the same as your corresponding heroku apps you can have an even shorter and more robust .git/hooks/pre-push hook:

    #!/bin/bash
    
    remote="$1"
    url="$2"
    
    if [[ $url =~ heroku ]] ; then
        hash_name=COMMIT_HASH
        hash=$(git rev-parse HEAD)
        echo Setting $hash_name to $hash on app $remote
        heroku config:set $hash_name=$hash --app $remote
    fi
    
    exit 0
    

提交回复
热议问题