Skip to content

Instantly share code, notes, and snippets.

@dennisoelkers
Last active July 15, 2020 07:57
Show Gist options
  • Save dennisoelkers/86296ddcf67fc962902c273e03e8ed65 to your computer and use it in GitHub Desktop.
Save dennisoelkers/86296ddcf67fc962902c273e03e8ed65 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Polling the status checks for a PR and merges it when they are green.
# Needs to be executed in the directory of the PR's repo.
#
# Args: merge-on-green <PR>
# where PR is the number of the PR without "#"
#
PR_NO=$1
while true; do
HEAD_COMMIT=`hub pr show -f "%sH" $PR_NO`
hub ci-status ${HEAD_COMMIT} > /dev/null && hub api -F merge_method=squash -X PUT repos/{owner}/{repo}/pulls/${PR_NO}/merge && exit 0
sleep 30
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment