Skip to content

Commit e5018c1

Browse files
authored
Fix workflows failing because releases weren't being found (#130)
GitHub [rate limits API requests](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28). The `install.sh` script uses the API through `curl` to determine the download URL for the correct PhotonVision jar file for each image. Building the images resulted in enough closely spaced calls to trigger the rate limit for some runners with the resulting response from the server: ``` {"message":"API rate limit exceeded for XXX.XXX.XXX.XXX. (But here'\''s the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)","documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"} ``` This PR fixes the problem by allowing then `install.sh` script to use the GITHUB_TOKEN to authenticate the request when it is running as a workflow.
1 parent d3badb2 commit e5018c1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ jobs:
9797
- name: Install dependencies and build image
9898
uses: photonvision/photon-image-runner@HEAD
9999
id: install_deps
100+
env:
101+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100102
with:
101103
minimum_free_mb: 2000
102104
image_url: ${{ matrix.base_image }}

install.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,15 @@ else
212212
RELEASE_URL="https://api.github.com/repos/photonvision/photonvision/releases/tags/$VERSION"
213213
fi
214214

215-
DOWNLOAD_URL=$(curl -sk "$RELEASE_URL" |
216-
grep "browser_download_url.*$ARCH_NAME.jar" |
215+
# use GITHUB TOKEN when available to authenticate
216+
if [[ -n $GH_TOKEN ]]; then
217+
RELEASES=$(curl -s -H "Authorization: Bearer $GH_TOKEN" "$RELEASE_URL")
218+
else
219+
RELEASES=$(curl -sk "$RELEASE_URL")
220+
fi
221+
222+
DOWNLOAD_URL=$(echo "$RELEASES" |
223+
grep "browser_download_url.*${ARCH_NAME}\.jar" |
217224
cut -d : -f 2,3 |
218225
tr -d '"'
219226
)

0 commit comments

Comments
 (0)