ghclass
ghclass copied to clipboard
Does this work with GH enterprise?
Hi.
We've been doing some test rounds with this package, works great on github, but we're struggling to get things working on github enterprise. Unsure if it's us or whether it's not possible to use with enterprise yet. Does the package rely on github actions to function properly, that's the only reason I could see why it would not work with enterprise at the moment.
I have not tested anything with GitHub enterprise since I haven't had access to an instance to develop against. ghclass uses the gh package for all of its interactions with the API and it looks like there is a .api_url
argument to the gh function which is likely necessary to point at the api end point for the enterprise installation.
Based on the docs for gh::gh
it looks like you can override this by setting a GITHUB_API_URL
environment variable - if you can try setting that via Sys.setenv()
before making a ghclass call hopefully things will work? I would be interested to hear how it goes.
My only other concern is that there may be minor differences in API version between enterprise and github.com - these are likely to be minor and so some functions might not work, but all of the core functionality should be solid.
Thank you for the tip on the api url. We'll see if that helps and let you know what works.
Hi.
I wanted to give some feedback of how far I got. I've successfully managed to set things up so that ghclass::github_test_token()
returns success, which I think is the first milestone.
Because I use both github.com and enterprise, I needed to make sure I had a setup that would allow me to use both. I opted for having my GITHUB_PAT
for github.com in my global .Renviron
and the GITHUB_PAT
for enterprise in project specific (i.e. class specific) .Renviron
. So, I'd need to remember to copy over this file for every class, but that is not too much hassle. One could opt for the opposite, if one uses the enterprise PAT more than github.com.
Secondly, since most of the ghclass
functions using gh
functions do not use ...
the best way to connect to another api is by adding to the .Renviron
(in my case the project specific one) a variable that gh
looks for when looking for an api to connect to. This is added through the GITHUB_API_URL
variable.
So for me, by project specific .Renviron
contains:
GITHUB_PAT=MYLONGPAT
GITHUB_API_URL="https://api.github.uio.no"
and that seems to get me authenticated correctly.
In this case, I think it is also important to note that people would have to remember to put .Renviron
in .gitignore
so that it does not get accidentally added to the repo.
Thanks for the feedback that is very helpful - I hadn't considered the PAT juggling that would be necessary with the different systems and that is good to keep in mind.
In the short term I will add some documentation to the vignette around GITHUB_API_URL
and .Renviron
Longer term I think we could make some quality of life improvements within the package to make all of this easier. I want to switch over to credentials
to handle the PAT stuff in general.
@jeroen it seems like credentials only supports a single PAT atm, any thoughts on if might be possible to allow for multiple PATs?