Skip to content

Instantly share code, notes, and snippets.

@maxrothman
Created March 27, 2017 18:09
Show Gist options
  • Save maxrothman/e4ea6a9ed66bd4c9678237081a97142e to your computer and use it in GitHub Desktop.
Save maxrothman/e4ea6a9ed66bd4c9678237081a97142e to your computer and use it in GitHub Desktop.
Wait for a PR to pass tests
#!/usr/bin/env bash
USAGE="Usage: wait-on-status OWNER REPO PR#"
[ -z $1 ] || [ -z $2 ] || [ -z $3 ] && echo $USAGE && exit 2
state="pending"
inloop=false
while [[ "$state" = "pending" ]]; do
$inloop && sleep 60
sha=$(curl -s https://api.github.com/repos/$1/$2/pulls/$3/commits | jq -r '.[-1].sha')
state=$(curl -s https://api.github.com/repos/$1/$2/commits/$sha/status | jq -r '.state')
inloop=true
done
msg="$1/$2 #$3 is ${state^^}"
echo -ne "\e]9;$msg\007"
echo "$msg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment