From b6ce2d0db891a2dee0bace10222dec06cb4c175b Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Tue, 24 Oct 2023 14:51:31 -0700 Subject: [PATCH] misc: Add GitHub Runner API rate limiting (#497) This stops the 'action-run.sh' from exhausting the GitHub API by adding sleeps. --- util/github-runners-vagrant/action-run.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/util/github-runners-vagrant/action-run.sh b/util/github-runners-vagrant/action-run.sh index e280b2f03a..67cc6f3cf8 100755 --- a/util/github-runners-vagrant/action-run.sh +++ b/util/github-runners-vagrant/action-run.sh @@ -62,6 +62,15 @@ while true; do token=$(echo ${token_curl} | jq -r '.token') + if [[ "${token}" == "null" ]]; + then + # If "null" is returned, this can be because the GitHub API rate limit + # has been exceeded. To be safe we wait for 15 mintues before + # continuing. + sleep 900 # 15 minutes. + continue + fi + # 2. Configure the runner. ./config.sh --unattended \ --url https://github.com/${GITHUB_ORG} \ @@ -78,4 +87,9 @@ while true; do # 4. Cleanup the machine sudo rm -rf "${WORK_DIR}" docker system prune --force --volumes --all + + # 5. Sleep for a few minutes + # GitHub has a api rate limit. This sleep ensures we dont ping GitHub + # too frequently. + sleep 180 # 3 minutes. done