Skip to content

Commit f4845fa

Browse files
committed
build: use authenticated mode for the merge script (angular#22269)
`TOKEN` is the name with use for other GH scripts PR Close angular#22269
1 parent f693be3 commit f4845fa

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

scripts/github/merge-pr

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,23 @@ if [ "$PR_NUMBER" -eq 0 ]; then
3838
exit 0
3939
fi
4040

41+
if [ -z ${TOKEN:-''} ]; then
42+
echo "############################################################"
43+
echo "############################################################"
44+
echo "WARNING: you should set the TOKEN variable to a github token"
45+
echo "############################################################"
46+
echo "############################################################"
47+
$GHCURL="curl"
48+
else
49+
$GHCURL="curl -H \"Authorization: token $TOKEN\""
50+
fi
51+
4152
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
42-
PULL_JSON=`curl -s https://api.github.com/repos/angular/angular/pulls/$PR_NUMBER`
53+
PULL_JSON=`$GHCURL -s https://api.github.com/repos/angular/angular/pulls/$PR_NUMBER`
4354
PR_SHA_COUNT=`node $BASEDIR/utils/json_extract.js commits <<< """$PULL_JSON"""`
4455
STATUS_JSON_URL=`node $BASEDIR/utils/json_extract.js _links.statuses.href <<< """$PULL_JSON"""`
45-
STATUS=`curl -s $STATUS_JSON_URL | node $BASEDIR/utils/json_extract.js description | cut -d '|' -f1`
46-
PR_LABELS=`curl -s https://api.github.com/repos/angular/angular/issues/$PR_NUMBER/labels`
56+
STATUS=`$GHCURL -s $STATUS_JSON_URL | node $BASEDIR/utils/json_extract.js description | cut -d '|' -f1`
57+
PR_LABELS=`$GHCURL -s https://api.github.com/repos/angular/angular/issues/$PR_NUMBER/labels`
4758
PR_ACTION=`echo "$PR_LABELS" | node $BASEDIR/utils/json_extract.js "name=^PR action:"`
4859
PR_TARGET=`echo "$PR_LABELS" | node $BASEDIR/utils/json_extract.js "name=^PR target:"`
4960
PR_CLA=`echo "$PR_LABELS" | node $BASEDIR/utils/json_extract.js "name=^cla"`
@@ -64,7 +75,7 @@ if [[ "$STATUS" != "All checks passed!" ]]; then
6475
echo PR $PR_NUMBER is failing with: $STATUS
6576
if [[ $FORCE == 1 ]]; then
6677
echo FORCING: --force flag used to ignor PR status.
67-
else
78+
else
6879
echo Exting...
6980
exit 1
7081
fi

0 commit comments

Comments
 (0)