Include a specific check for github API limit being hit

This commit is contained in:
popcornmix
2017-05-30 14:27:08 +01:00
parent 72cb59c7f5
commit a8e2f8503b

View File

@@ -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"