-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add support for GHE #618
base: main
Are you sure you want to change the base?
Add support for GHE #618
Conversation
By providing github-api-url we can enable support for Github Enterprise. In some cases it might be available for octokit automatically but it's safer to provide an override.
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 for addressing around this feature!
I don't have experience to use GHE, but the logic and suggestion looks good.
I have reviewed about some CI failures and parameters. 🙏
@@ -9,6 +9,10 @@ inputs: | |||
description: 'The GITHUB_TOKEN secret' | |||
required: true | |||
default: ${{ github.token }} | |||
github-api-url: |
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.
github-api-url: | |
github-graphql-url: |
I think this will be better to clarify the difference of REST endpoints
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.
In this case - octokit graphql actually does "magic" to figure out graphql endpoint from rest endpoint here:
https://github.com/octokit/graphql.js/blob/main/src/graphql.ts#L67
If we pass graphql endpoint as baseUrl
it would produce url such as "https://ghe.example.net/graphql/graphql".
So in this case we need to leave it as github-api-url
. Or if you'd prefer github-rest-api-url
?
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.
https://github.com/octokit/graphql.js/blob/9c0643d34f36ed558e55193438d7aa8b031ca43d/src/graphql.ts#L23
https://github.com/octokit/graphql.js/blob/9c0643d34f36ed558e55193438d7aa8b031ca43d/src/graphql.ts#L67-L72
const GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/;
// workaround for GitHub Enterprise baseUrl set with /api/v3 suffix
// https://github.com/octokit/auth-app.js/issues/111#issuecomment-657610451
const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl;
if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {
requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql");
}
If we pass graphql endpoint as baseUrl it would produce url such as "https://ghe.example.net/graphql/graphql".
The workaround seems to focus only on the /api/v3
suffix. Did it actually append nested graphql suffix for your URL?
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.
So we have https://ghe.example.com/api/v3
for the api_url. When I use it I end with following error (redacted):
const error2 = new import_request_error.RequestError(toErrorMessage(data), status, {
RequestError [HttpError]: Not Found
at main/dist/index.js:18839:26
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.next (main/dist/index.js:21920:32)
at async Function.paginate (main/dist/index.js:21968:26)
at async getCheckRunSummaries (main/dist/index.js:25927:55)
at async fetchOtherRunStatus (main/dist/index.js:26018:27)
at async run (main/dist/index.js:26183:20) {
status: 404,
response: {
url: 'https://ghe.example.com/api/graphql/graphql',
status: 404,
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.
github.api_url
may raise the error, but your ${{ github.graphql_url }}
have same suffix? As I understand it, GitHub GraphQL API is v4. (I may not know GHE backgrounds 🙇♂️ )
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.
In our GHE instance ${{ github.graphql_url }}
resolves to something like: https://ghe.example.net/api/graphql
(which is correct endpoint for it). So the octokit graphql takes: https://ghe.example.net/api/v3
and replaces api/v3
with api/graphql
. Otherwise it appends graphql
(assuming baseURL is api.github.com
). Which is why we need to just give octokit ${{ github.api_url }}
. It figures out graphql endoint on its own.
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 for sharing! I'm reading how some other actions are handling this ....
https://github.com/google-github-actions/release-please-action/pull/532
- use github.api_url variable - reformat README.md a bit
02d65dd
to
6690a97
Compare
Not sure if there's anything more I should be fixing here. |
Sorry for my delayed reply 🙇 Your implementation looks good to me 👍 , but I have stacked to determine the input naming A fundamental problem is that I don't have an environment to test GitHub Enterprise Edition... |
By providing github-api-url we can enable support for Github Enterprise.
In some cases it might be available for octokit automatically but it's
safer to provide an override.