Skip to content

Commit 8d0b125

Browse files
haggaiewebispy
authored andcommitted
pass GITHUB_TOKEN to API if it is set
Currently the GITHUB_TOKEN environment variable is not used. Pass it to the github API when reading the command list to allow accessing private repositories. Signed-off-by: Haggai Eran <haggaie@nvidia.com>
1 parent 3ade5c3 commit 8d0b125

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

entrypoint.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ RESULT=0
2020
echo
2121
if [[ -z "$GITHUB_TOKEN" ]]; then
2222
echo -e "\e[0;34mToken is empty. Review PR without comments.\e[0m"
23+
HEADERS=()
2324
else
2425
echo -e "\e[0;34mReview PR with comments.\e[0m"
26+
HEADERS=(-H "Authorization: Bearer $GITHUB_TOKEN")
2527
fi
2628

2729
# Get commit list using Github API
@@ -32,7 +34,7 @@ PRNUM=${PR%"/merge"}
3234
URL=https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PRNUM}/commits
3335
echo " - API endpoint: $URL"
3436

35-
list=$(curl $URL -X GET -s | jq '.[].sha' -r)
37+
list=$(curl $URL "${HEADERS[@]}" -X GET -s | jq '.[].sha' -r)
3638
len=$(echo "$list" | wc -l)
3739
echo " - Commits $len: $list"
3840

0 commit comments

Comments
 (0)