-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from gm3dmo/sn2b-patch-1
Create search-rate-limit-demo.sh
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
. .gh-api-examples.conf | ||
|
||
# https://docs.github.com/en/enterprise-cloud@latest/rest/search?apiVersion=2022-11-28#search-repositories | ||
# https://docs.github.com/en/enterprise-cloud@latest/rest/search?apiVersion=2022-11-28#rate-limit | ||
# https://api.github.com/search/repositories?q=Q | ||
|
||
# WORKS ON A MAC | ||
default_start_date="$(date -v -7d +'%Y-%m-%d')" | ||
|
||
# Pass query as an argument, otherwise list all repos with commits in the last seven days | ||
if [ -z "$1" ] | ||
then | ||
query="pushed:>$default_start_date" | ||
else | ||
query="$1" | ||
fi | ||
|
||
# adjusted from search-repositories.sh to hit the 30 requests per minute rate limit | ||
for n in {1..31} | ||
do | ||
echo "position in loop ${n}" | ||
# verbose curl but no output from the curl, since it is not interesting for rate limit demo purposes | ||
curl -v ${curl_custom_flags} \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
${GITHUB_API_BASE_URL}/search/repositories?q=${query} > /dev/null | ||
done |