Skip to content

Instantly share code, notes, and snippets.

@caseycoding
Last active January 5, 2018 19:34
Show Gist options
  • Save caseycoding/7a9b5b89f9bc886296582dabe692c43f to your computer and use it in GitHub Desktop.
Save caseycoding/7a9b5b89f9bc886296582dabe692c43f to your computer and use it in GitHub Desktop.
pr_opener
AUTH_HEADER='"Authorization: bearer HEREHEREHEREHEREHEREHEREHEREHEREHEREHEREHEREHERE"'
ACCEPT_HEADER='"Accept: application/vnd.github.v3+json"'
# Message within the pr
BODY="Script generated pull request"
# TESTING
# OWNER=caseycoding
# REPOS=(caseycoding.github.io tic-tac-toe)
# BRANCHES=(caseycoding.github.io tic-tac-toe)
# LIVE
OWNER=
REPOS=()
# If your branches have suffixes uncomment the line below and #s 19,27-28 and update the payload variables
# BRANCHES=()
HEAD=${1:-dev} #The name of the branch where your changes are implemented.
BASE=${2:-master} #The name of the branch you want the changes pulled into.
# TITLE=${3:-$BASE"->"$HEAD}
TITLE=$(echo $HEAD"->"$BASE | awk '{print toupper($0)}')
echo $TITLE
for i in $(seq 0 $(expr ${#REPOS[@]} - 1)); do
# echo $i
# HEAD_BRANCH=${BRANCHES[$i]}"-"$HEAD
# BASE_BRANCH=${BRANCHES[$i]}"-"$BASE
ROUTE=https://api.github.com/repos/$OWNER/${REPOS[$i]}/pulls
PAYLOAD='{"title": "'$TITLE'","head": "'$HEAD'","base": "'$BASE'","body": "'$BODY'"}'
curlCmd="curl -s -H $AUTH_HEADER -H $ACCEPT_HEADER -X POST $ROUTE -d '$PAYLOAD'"
# echo $curlCmd
eval $curlCmd | jq 'if ._links.html then ._links.html.href else .errors[0].message end'
# echo REPOS[$i]
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment