Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GITHUB_TOKEN optional for local development? #266

Closed
mandrasch opened this issue Oct 25, 2024 · 11 comments
Closed

Make GITHUB_TOKEN optional for local development? #266

mandrasch opened this issue Oct 25, 2024 · 11 comments

Comments

@mandrasch
Copy link
Collaborator

mandrasch commented Oct 25, 2024

In my personal opinion it is a bit of a challenge that people who want to add a blog article PR need to setup a GitHub key first.

They also might not understand why they have to do it on their own account. An information what the key does is also missing in README.md

And ... first it works without a token, but then you run into the GitHub API rate limit errors when you try ddev npm run build.

My proposal would be something like this for api.ts:

export async function getSponsors() {

  if(!process.env.hasOwnProperty('GITHUB_TOKEN') || process.env.GITHUB_TOKEN === ''){
    return [];
  }

If there is not GITHUB_TOKEN, we simply don't render sponsors, contributors, latest releases.

We might add a warning if this is a production build and the GITHUB_TOKEN is still missing.

(Goal: Make it as easy as possible to contribute, guess adding blog articles via Gitpod would also be great)

@rfay
Copy link
Member

rfay commented Oct 25, 2024

Wow, I never set GITHUB_TOKEN. I just ddev start and move on. Maybe I have something set that I don't understand?

@rfay
Copy link
Member

rfay commented Oct 25, 2024

I guess it's because I don't ever rebuild those, and I guess that must not be required.

@rfay
Copy link
Member

rfay commented Oct 25, 2024

It would be a fine addition, thanks!

@mandrasch
Copy link
Collaborator Author

mandrasch commented Oct 25, 2024

You have this cached in cache/ most probably already, there is a nice caching mechanism in api.ts:

const cacheFilename = 'releases.json'
const cachedData = getCache(cacheFilename);

When I cleared my cache/-folder today, and ran ddev npm run build - I had this (no GITHUB_TOKEN set):

16:19:39 ▶ src/pages/about.astro
16:19:39   └─ /about/index.htmlRequest quota exhausted for request POST /graphql

@rfay
Copy link
Member

rfay commented Oct 25, 2024

My first time up on a new machine I also got this:

08:22:41 └─ /about/index.htmlRequest quota exhausted for request POST /graphql

And it also seems to hang forever there.

@rfay
Copy link
Member

rfay commented Oct 25, 2024

I imagine I had a .env on other machine that I wasn't aware of.

Note that it seems to work with a no-scope-no-privileges token (I don't think it needs the privs currently stated in the README)

@mandrasch
Copy link
Collaborator Author

Created draft #268

@mandrasch
Copy link
Collaborator Author

mandrasch commented Oct 25, 2024

Note that it seems to work with a no-scope-no-privileges token (I don't think it needs the privs currently stated in the README)

Ah interesting! Briefly wondered why these are needed when you are someone with no privs for github.com/ddev in the first place

@mandrasch
Copy link
Collaborator Author

mandrasch commented Oct 25, 2024

no-scope-no-privileges does not work

Your token has not been granted the required scopes to execute this query. The 'login' field requires one of the following scopes: ['read:org'], but your token has only been granted the: [''] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.

Your token has not been granted the required scopes to execute this query. The 'login' field requires one of the following scopes: ['read:org'], but your token has only been granted the: [''] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
 - Your token has not been granted the required scopes to execute this query. The 'url' field requires one of the following scopes: ['read:org'], but your token has only been granted the: [''] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
 - Your token has not been granted the required scopes to execute this query. The 'avatarUrl' field requires one of the following scopes: ['read:org'], but your token has only been granted the: [''] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
 - Your token has not been granted the required scopes to execute this query. The 'login' field requires one of the following scopes: ['read:org'], but your token has only been granted the: [''] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
 - Your token has not been granted the required scopes to execute this query. The 'url' field requires one of the following scopes: ['read:org'], but your token has only been granted the: [''] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
 - Your token has not been granted the required scopes to execute this query. The 'avatarUrl' field requires one of the following scopes: ['read:org'], but your token has only been granted the: [''] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.

I'm an "outside collaborator on 1 repository" for ddev organization, so a test with someone not added to ddev org would be helpful.

@stasadev
Copy link
Member

I have a GitHub account without DDEV access, and confirm that read:org scope is enough for ddev start.
I'm not sure why other scopes are listed in README.md: repo, read:user, and read:project.

@rfay
Copy link
Member

rfay commented Nov 1, 2024

This was fixed in

Thanks!

@rfay rfay closed this as completed Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants