benallfree / gobot

Popular binaries via npm. CLI and API.
22 stars 2 forks source link

Respect GITHUB_TOKEN when fetching via GithubReleaseProvider #1

Closed TsFreddie closed 8 months ago

TsFreddie commented 8 months ago

Tried to use gobot at work. Got hit by rate limits (probably because there are other GitHub api callers in the building)

> Fetching info for pocketbase/pocketbase releases page 1...
> Error: API down and no cache https://api.github.com/repos/pocketbase/pocketbase/releases?per_page=100&page=1

The api returns a 403 status code with the following body.

{"message":"API rate limit exceeded for <redacted ip address>. (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 patch checks the GITHUB_TOKEN environment variable and pass the Authorization header accordingly.

The convention of checking GITHUB_TOKEN is similar to GitHub CLI as documented in the manual and, more familiarly to some, inside GitHub Actions.

benallfree commented 8 months ago

Thank you so much!

Out of curiosity, which app were you testing with?

TsFreddie commented 8 months ago

Out of curiosity, which app were you testing with?

pocketbase. I was on pockethost as well, but I just figured trying out hooks is probably faster locally, and gobot feels easier to launch. Thanks for the tools.