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
Allows API URL override via environment variable to support GitHub Enterprise #24
Conversation
I bumped the version to 1.4.0 to avoid potentially breaking existing users. |
There is a much simpler way to support GHE in actions. I've done the following in my own actions.
This is also how it's done in the official actions like checkout: |
Thanks for the advice Peter. I can't get this to work on my end, though. I see your action is mainly working with the actions toolkit (actions/core in the case you linked); however, this action is leveraging octokit directly. The octokit/auth-app.js library delegates to octokit/endpoint.js, which hard codes https://github.com/octokit/endpoint.js/blob/master/src/defaults.ts#L12 I don't see any place where auth-app.js, request.js, or endpoint.js are reading |
For overriding const options: OctokitOptions = {}
if (token) {
options.auth = `${token}`
}
options.baseUrl = process.env['GITHUB_API_URL'] || 'https://api.github.com'
this.octokit = new Octokit(options) See: https://github.com/peter-evans/create-pull-request/blob/main/src/github-helper.ts#L27 |
Sure. That simplifies things. |
Nice. LGTM but I'm not the maintainer 😄 |
Thanks for the help though :) |
After looking at getOctokit in the github package I'm not sure if this change is necessary. The toolkit already includes this env var lookup for the base URL here: https://github.com/actions/toolkit/blob/f0b00fd201c7ddf14e1572a10d5fb4577c4bd6a2/packages/github/src/internal/utils.ts#L23-L25 @retiman Are you sure this action doesn't work on GHE already? |
Yea, I verified it doesn't work if The link you sent me is for the actions toolkit, where that makes more sense. The toolkit code is meant to be run in build agents and the |
Co-authored-by: Thibault Derousseaux <6574550+tibdex@users.noreply.github.com>
@retiman Let me try and break down the route this action takes to build it's Octokit instance and you'll see that
A new
You can see the code exists in the So the Octokit instance used by this action should already have the correct base URL set if |
@peter-evans I don't deny this is happening at the actions toolkit level; all the links you gave are code paths into However, when using a non-modified version of this action in GHE, I'm hitting the 404 error on line 15 in https://github.com/tibdex/github-app-token/blob/main/src/fetch-installation-token.ts#L15 The https://github.com/octokit/auth-app.js/blob/master/src/index.ts#L49 You'll see in https://github.com/octokit/endpoint.js/blob/master/src/index.ts#L4 Stepping back a bit, do you believe that the env var should be checked in octokit? EDIT: grammar |
Ah, sorry. 🙏 I was getting confused because I didn't read the code properly and assumed this was about the octokit instance in use, but it's about the (No I don't think |
No worries, thanks for following up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, let's see how this works.
Just tested against GHE; works great. |
Fixes #23.