mirror of
https://github.com/raspberrypi/rpi-update.git
synced 2026-01-20 21:13:38 +08:00
Include a specific check for github API limit being hit
This commit is contained in:
@@ -54,6 +54,13 @@ if [[ -n "${GITHUB_API_TOKEN}" ]]; then
|
|||||||
GITHUB_AUTH_PARAM="--header \"Authorization: token ${GITHUB_API_TOKEN}\""
|
GITHUB_AUTH_PARAM="--header \"Authorization: token ${GITHUB_API_TOKEN}\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
GITHUB_API_LIMITED=$(eval curl -Ls ${GITHUB_AUTH_PARAM} https://api.github.com/rate_limit | awk 'BEGIN {reset=0;} { if ($1 == "\"limit\":") limit=strtonum($2); else if ($1 == "\"remaining\":") remaining=strtonum($2); else if ($1 == "\"reset\":" && limit>0 && remaining==0) reset=strtonum($2);} END { print reset }')
|
||||||
|
if [ ${GITHUB_API_LIMITED} -gt 0 ]; then
|
||||||
|
echo " *** Github api is currently rate limited - please try again after $(date --date @${GITHUB_API_LIMITED})"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
function update_self() {
|
function update_self() {
|
||||||
echo " *** Performing self-update"
|
echo " *** Performing self-update"
|
||||||
_tempFileName="$0.tmp"
|
_tempFileName="$0.tmp"
|
||||||
|
|||||||
Reference in New Issue
Block a user