Skip to content

Instantly share code, notes, and snippets.

@AntonTyutin
Created May 19, 2016 18:02
Show Gist options
  • Save AntonTyutin/7ef9006364b5649388d7a52c848e97f5 to your computer and use it in GitHub Desktop.
Save AntonTyutin/7ef9006364b5649388d7a52c848e97f5 to your computer and use it in GitHub Desktop.
Make GitHub pull-request from an issue
#!/bin/bash
// export GITHUB_API_TOKEN=051e00e0fd07b55f661da8c3068befa06518227e
NL="
"
NL2="$NL$NL"
HELP="$NL2 Usage: $0 vendor/repo feature_branch 15 master$NL Make sure you export GITHUB_API_TOKEN environment variable$NL2"
REPO=${1:?"$NL2 A repository name (vendor/repo) must be specified.$HELP"}
HEAD=${2:?"$NL2 A branch name must be specified.$HELP"}
ISSUE=${3:?"$NL2 An issue id must be specified.$HELP"}
BASE=${4:-'master'}
curl \
-H "Authorization: token $GITHUB_API_TOKEN" \
--request POST \
--data "{\"issue\": \"$ISSUE\", \"head\": \"$HEAD\", \"base\": \"$BASE\"}" \
"https://api.github.com/repos/$REPO/pulls"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment