ddev / ddev.com

Astro source code used to generate the static, public ddev.com site.
https://ddev.com
Apache License 2.0
12 stars 19 forks source link

Make GITHUB_TOKEN optional for local development? #266

Open mandrasch opened 5 days ago

mandrasch commented 5 days ago

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 commented 5 days ago

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

rfay commented 5 days ago

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

rfay commented 5 days ago

It would be a fine addition, thanks!

mandrasch commented 5 days ago

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 commented 5 days ago

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 commented 5 days ago

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 commented 5 days ago

Created draft https://github.com/ddev/ddev.com/pull/268

mandrasch commented 5 days ago

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 commented 5 days ago

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 commented 5 days ago

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.