Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created April 15, 2023 19:01
Show Gist options
  • Select an option

  • Save KyMidd/cf4119e6037cecd6b03891faa94d3b20 to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/cf4119e6037cecd6b03891faa94d3b20 to your computer and use it in GitHub Desktop.
# If API rate-limiting is hit, sleep for 1 minute
# Rounded parenthesis are used to trigger arithmetic expansion, which compares more than the first numeric digit (bash is weird)
if (( "$API_RATE_LIMIT_UNITS_REMAINING" < 100 )); then
echo "ℹ️ We have less than 100 GitHub API rate-limit tokens left, sleeping for 1 minute"
sleep 60
# If API rate-limiting shows remaining units, break out of loop and function
else
echo ℹ️ Rate limit checked, we have "$API_RATE_LIMIT_UNITS_REMAINING" core tokens remaining so we are continuing
break
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment