Skip to content

Instantly share code, notes, and snippets.

@gshutler
Created August 4, 2013 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gshutler/6150489 to your computer and use it in GitHub Desktop.
Save gshutler/6150489 to your computer and use it in GitHub Desktop.
Tagging a commit with build status on GitHub
#! /usr/bin/env bash
# Examples
#
# $ gh-build-notification.sh pending "Build in progress"
# $ gh-build-notification.sh failure "Build failed"
# $ gh-build-notification.sh success "Build succeeded"
commit=`git rev-parse HEAD`
json="{\"state\":\"$1\",\"description\":\"$2\",\"target_url\":\"$BUILD_URL\"}"
echo "Sending notification to Github"
echo $json
# http://developer.github.com/v3/repos/statuses/#create-a-status
curl \
-X POST \
-H "Authorization: token API-TOKEN" \
-H "User-Agent: Shell build notifier" \
-d "$json" \
--silent \
--output /dev/null \
https://api.github.com/repos/OWNER/REPO/statuses/$commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment