Skip to content

Instantly share code, notes, and snippets.

@djeikyb
Created November 6, 2018 01:13
Show Gist options
  • Save djeikyb/efd40d7cd67bc6e73c19c951d5533271 to your computer and use it in GitHub Desktop.
Save djeikyb/efd40d7cd67bc6e73c19c951d5533271 to your computer and use it in GitHub Desktop.
for when the build server breaks without a pull request
#!/bin/sh
repo="d3sw/falkor"
token=${GITHUB_TOKEN:?}
localref=${1:-HEAD}
remoteBranch=${2:-jacobstaging}
merge() {
http \
--check-status \
--ignore-stdin \
put \
https://api.github.com/repos/"$repo"/pulls/"$pr_number"/merge \
Accept:'application/vnd.github.v3+json' \
Authorization:"bearer $token" \
merge_method=merge
}
publishBranch() {
git push -f origin "$localref":"refs/heads/$remoteBranch"
}
createPr() {
http \
--check-status \
--ignore-stdin \
post \
https://api.github.com/repos/"$repo"/pulls \
Accept:'application/vnd.github.v3+json' \
Authorization:"bearer $token" \
title="$remoteBranch" \
head="$remoteBranch" \
base=master \
maintainer_can_modify:=true
}
deleteBranch() {
git push --delete origin "$remoteBranch"
}
pr_number=$(publishBranch && createPr | jq --raw-output '.number')
merge && deleteBranch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment