[maintainer-tools PATCH 1/4] github-merge-pr: Use GITHUB_TOKEN for API access

Hauke Mehrtens hauke at hauke-m.de
Sat Jul 6 09:07:22 PDT 2024


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 <hauke at 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




More information about the openwrt-devel mailing list