Created
November 6, 2018 01:13
-
-
Save djeikyb/efd40d7cd67bc6e73c19c951d5533271 to your computer and use it in GitHub Desktop.
for when the build server breaks without a pull request
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/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