Last active
March 30, 2017 01:25
-
-
Save sridharavinash/7317567bcff33027942f363ff1727b89 to your computer and use it in GitHub Desktop.
Branch build status on command line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Export $GITHUB_TOKEN with your access token | |
# | |
function get_build_status(){ | |
branch=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') | |
repo=$(git config --get remote.origin.url | egrep -Eo '/(\w+)' | cut -d '/' -f 2) | |
status=$(curl -s -u "$GITHUB_TOKEN:x-oauth-basic" https://api.github.com/repos/github/$repo/commits/$branch/status | jq '.state' | tr -d '"') | |
case $status in | |
"success") | |
echo -e " \xE2\x9C\x85 " | |
;; | |
"failure") | |
echo -e "\xE2\x9D\x8C " | |
;; | |
"pending") | |
echo -e "\xE2\x97\x94" | |
;; | |
*) | |
echo "" | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment