Replies: 1 comment 7 replies
-
|
Hey @escarls 👋 apologies for the friction here. I want to say first off, that this is great feedback - so thank you 🙇 Second, an explanation for why we chose If I'm reading this right, it sounds what you're looking for is a token environment variable specifically for GitHub enterprise cloud tenants, that would override
There's probably some code in |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
At my previous employer, we used github as an org on github.com.
Back then, I used github cli with only the GH_TOKEN environment variable and no config file.
That worked like a charm for work and hobby projects, as they could in theory just use the same token.
My new employer however, have github enterprise hosted at company.ghe.com
And since it was Github Enterprise, I assumed it was just to follow the docs and have two tokens.
The GH_TOKEN for regular github and GH_ENTERPRISE_TOKEN for the company.ghe.com.
Well, that didn't work well.
So I discovered in the doc that I needed to set the GH_HOST environment variable when I was in a work repo, so gh would access the correct api. But still no go.
With the setup:
GH_TOKEN=
GH_ENTERPRISE_TOKEN=
GH_HOST=<company.ghe.com>
I only got error that the token was invalid.
So after spending some time testing back and forth, different things, like:
GH_COMPANY_GHE_COM_TOKEN=
and so on, nothing worked.
Then I just tested for fun:
How about if I just do:
GH_TOKEN=
Then everything worked (sort of).
gh auth statusshowed me this output:
Then I started looking into the github cli code a bit and then I understood why it was like this.
The unit tests for the IsEnterprise function expects "tenant.ghe.com" to return false, and I guess (didn't check) that this is the reason that the GH_ENTERPRISE_TOKEN env variable is not used.
So because of this, how can I create a setup, where I only have to set/unset GH_HOST to switch between work (ghe.com) and hobby projects (github.com)?
The reason for not wanting to use the "gh auth login" and create config, is that I'm mostly developing in devcontainers and then it's alot easier to just work with env variables for everything.
Also looking at the output from gh auth status, it seems there are more things going on there also.
I would have expected the output to just show the company.ghe.com part, as I have nothing here that hints to github.com, except for the GH_TOKEN variable, that was required for my company.ghe.com host.
Beta Was this translation helpful? Give feedback.
All reactions