Use the GITHUB_TOKEN also for the public https://api.github.com
accesses. Over some networks like public hotspots github is blocking
unauthenticated access.

Signed-off-by: Hauke Mehrtens <ha...@hauke-m.de>
---
 github-merge-pr.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/github-merge-pr.sh b/github-merge-pr.sh
index dd08a89..db49c92 100755
--- a/github-merge-pr.sh
+++ b/github-merge-pr.sh
@@ -77,7 +77,13 @@ if [ -z "$(git branch --list "$BRANCH")" ]; then
        exit 2
 fi
 
-if ! PR_INFO="$(curl -f -s "https://api.github.com/repos/$REPO/pulls/$PRID";)"; 
then
+if [ -n "$GITHUB_TOKEN" ]; then
+       CURL_CMD=" --user \"$GITHUB_TOKEN:x-oauth-basic\" "
+else
+       CURL_CMD=" "
+fi
+
+if ! PR_INFO="$(curl $CURL_CMD -f -s 
"https://api.github.com/repos/$REPO/pulls/$PRID";)"; then
        echo "Failed fetch PR #$PRID info" >&2
        exit 3
 fi
-- 
2.45.2


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to