github-branch-pr-number

github-branch-pr-number
gets GitHub PullRequst number from branch name through GitHub API.
Installation
Install github-branch-pr-number using go get
command:
$ go get github.com/evalphobia/github-branch-pr-number
Usage
$ github-branch-pr-number
[ERROR] 2017/05/19 14:21:26 GitHub API token is missing.
usage:
$ github-branch-pr-number -token="<GitHub API Token>" -project="<GitHub project name>" -branch="<branch name>"
ex) github-branch-pr-number -token="this_is_secret" -project="evalphobia/github-branch-pr-number" -branch="develop"
# if https://github.com/evalphobia/github-branch-pr-number/pull/34 is exists and still open, and this Ref branch is same as current HEAD.
$ github-branch-pr-number -token="this_is_secret" -project="evalphobia/github-branch-pr-number" -branch=`git rev-parse --abbrev-ref HEAD`
34
But What For?
For Pull Request review comment by bot.
reviewdog needs PR number(CI_PULL_REQUEST env variable).
But some CI or your original CI might not conatain PR number info.
If you cannot get PR number but want to send review comment to GitHub by Bot/CI/etc, github-branch-pr-number
might help.
Parameters
flag option
name |
required |
description |
example |
-token |
yes |
GitHub API Token to perform API request |
get this from here: https://github.com/settings/tokens |
-branch |
yes |
Git branch name for the Pull Request (Ref) |
master , develop , $(git rev-parse --abbrev-ref HEAD) |
-project |
* |
GitHub project name |
evalphobia/github-branch-pr-number , google/go-github , github/hubot |
-owner |
* |
GitHub owner name (project is: evalphobia/github-branch-pr-number , then owner is: evalphobia ) |
evalphobia , google , github |
-repo |
* |
GitHub repository name (project is: evalphobia/github-branch-pr-number , then repository is: github-branch-pr-number ) |
github-branch-pr-number , go-github , hubot |
-size |
no |
How many latest updated pull requests are searched by this tool (default: 50) |
10 , 30 , 100 |
*
At least, either [-project
] or [-owner
and -repo
] is required.
env var
name |
description |
GITHUB_API_TOKEN |
Used as GitHub API Token if -token is not set |
REVIEWDOG_GITHUB_API_TOKEN |
(same as above) |