Skip to content

Commit 0458308

Browse files
Rate limit
1 parent 3171fb0 commit 0458308

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

{{cookiecutter.project_slug}}/.github/workflows/auto_merge.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ jobs:
2020
runs-on: ubuntu-latest
2121
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
2222
steps:
23+
- name: Check rate limit
24+
id: rate-limit
25+
shell: bash
26+
run: |
27+
RATE_LIMIT=$(gh api /rate_limit | jq -r '.resources.core.remaining')
28+
echo "::set-output name=remaining::$RATE_LIMIT"
29+
if [[ "$RATE_LIMIT" -lt 10 ]]; then
30+
RESET_TIME=$(gh api /rate_limit | jq -r '.resources.core.reset')
31+
echo "::set-output name=reset_time::$RESET_TIME"
32+
echo "Rate limit is low ($RATE_LIMIT). Waiting until $RESET_TIME"
33+
sleep $((RESET_TIME - $(date +%s)))
34+
fi
2335
- name: Dependabot metadata
2436
id: dependabot-metadata
2537
uses: dependabot/fetch-metadata@v1.3.1

0 commit comments

Comments
 (0)