I have written a shell script to create a pull request with Github Enterprise API.
#!/bin/sh
CURRENT_BRANCH=$(git branch --show-current)
git stash save
git checkout master
git pull
UUID=$(uuidgen)
git checkout -b "${UUID}"
npm version patch
git add package.json
git commit -m "#; update version script test"
git push origin "${UUID}"
curl -u [MY_USER_NAME]:[MY_TOKEN] https://github.[MY_ORGANIZATION].com/api/v3/user
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://github.[MY_ORGANIZATION].com/api/v3/repos/Modules/[MY_REPO]/pulls \
-d "{'head':'${UUID}','base':'master'}"
The log is displayed as below. It fail to create the pull request with the error
"message": "Must authenticate to access this API."
However, there seems no issue with the authentication.
// omit some useless log here
remote:
To github.microstrategy.com:Modules/mstr-web-hierarchy.git
* [new branch] 23CFA0E3-33D1-489E-9E55-D38F92BB1B99 -> 23CFA0E3-33D1-489E-9E55-D38F92BB1B99
{
"login": "shizhang",
"id": 1191,
// some useless properties here
{
"message": "Must authenticate to access this API.",
"documentation_url": "https://docs.github.com/enterprise/3.0/rest"
}