-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add recipe to test github api limits
- Loading branch information
Showing
1 changed file
with
43 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,43 @@ | ||
--- | ||
Description: Example recipe getting the github api limits | ||
Identifier: com.github.jgstew.test.ExampleGitHubAPI | ||
Input: | ||
NAME: ExampleGitHubAPI | ||
MinimumVersion: "2.3" | ||
Process: | ||
- Processor: com.github.jgstew.SharedProcessors/SharedUtilityMethods | ||
|
||
- Processor: FileFinder | ||
Arguments: | ||
# create a read only limited personal access token on GitHub.com | ||
# set the expiration to 1 year | ||
# put the token in this file: | ||
pattern: "/Users/*/.autopkg_gh_token" | ||
|
||
- Processor: com.github.jgstew.SharedProcessors/FileTextSearcher | ||
Arguments: | ||
search_path: "%found_filename%" | ||
file_search_results_var: "GITHUB_TOKEN" | ||
# match all characters that are not whitespace: | ||
search_pattern: '\S+' | ||
first_result_only: True | ||
|
||
- Processor: URLTextSearcher | ||
Arguments: | ||
# example using gh command: `gh api --method GET /rate_limit` | ||
url: https://api.github.com/rate_limit | ||
curl_opts: ["-H", "Authorization: token %GITHUB_TOKEN%"] | ||
# the GITHUB_API_LIMIT should be 5000: | ||
re_pattern: '(?m)"rate":\s*{[\s\n\r]+"limit":\s*(?P<GITHUB_API_LIMIT>\d+),[\s\n\r]+"used":\s*(?P<GITHUB_API_USED>\d+)' | ||
# Example Match: | ||
# "rate": { | ||
# "limit": 5000, | ||
# "used": 3, | ||
# "remaining": 4997, | ||
# "reset": 1677627218 | ||
# } | ||
|
||
- Processor: EndOfCheckPhase | ||
Arguments: | ||
# clear token so it isn't saved in plist | ||
GITHUB_TOKEN: "" |