feat: Add support for GHE / Data Residency and GHES - #480
Conversation
…jects#479) Make all GitHub host references configurable via environment variables so the app can run against GHE.com Data Residency tenants (*.ghe.com) and GitHub Enterprise Server, in addition to github.com. - New helpers in src/utils/github-urls.ts derive server/API/OAuth URLs from GITHUB_SERVER_URL (with smart derivation: github.com -> api.github.com, *.ghe.com -> api.<tenant>.ghe.com, anything else -> <server>/api/v3). GITHUB_API_URL overrides derivation. - Octokit (bot/rest.ts) and Probot (pages/api/webhooks.ts) are configured with the derived baseUrl. createAppAuth requests also use the configured base URL via @octokit/request defaults. - NextAuth GitHub provider routes authorization/token/userinfo through the configured GHE host and uses a custom userinfo.request to fetch /user/emails from the configured API host (next-auth v4 hardcodes api.github.com otherwise). OAuth refresh URL uses env. - generateAuthUrl builds git remotes from GITHUB_SERVER_URL host. - Committer email domain is configurable via GITHUB_USER_EMAIL_DOMAIN (default users.noreply.github.com preserves current behavior). - UI components use getGitHubServerUrl() for fork/org links; client bundles read NEXT_PUBLIC_GITHUB_SERVER_URL / NEXT_PUBLIC_GITHUB_API_URL inlined at build time. - webhook-relay.mjs script wires baseUrl into octokit.App and warns when not targeting github.com (polling endpoint is best-effort on GHE). - .env.example and docs (README.md, docs/developing.md) document the GHE.com / GHES configuration and Docker build-arg requirement. - Added tests for URL derivation covering github.com defaults, GHE.com Data Residency, GHES, and explicit overrides. Defaults are unchanged, so existing github.com / GHEC deployments continue to work without any new configuration. Closes github-community-projects#479 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…-support feat: add GHE.com Data Residency / GHES support (github-community-projects#479)
fix: correct GHES URL wiring and Docker client build args
|
@wrslatz it should be ready for review 👍 |
riley-kohler
left a comment
There was a problem hiding this comment.
Apologies for the delay in review. I think we should lean on users setting all of the custom environment variables if necessary instead of attempting to derive values from those that are passed in. There is a lot of logic here that is hard to verify and will be hard to maintain in case GitHub changes URL structure or adds a new type of environment in the future. If there are GitHub provided functions that do this sort of thing we could lean on those but barring that I think that envs will be much easier to implement, test, and maintain.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Matteo Bianchi <37507190+mbianchidev@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Matteo Bianchi <37507190+mbianchidev@users.noreply.github.com>
…xport refactor: remove derive GitHub URL functionality in favor of explicit setup
refactor: resolve upstream conflicts and simplify GitHub config
wrslatz
left a comment
There was a problem hiding this comment.
Apologies for the delay in review here! I left a few suggestions, but none of them are blocking. Thanks for this great contribution that makes Private Mirrors work for more people and be more flexible in its config ❤️
…d-octokit refactor: improve GitHub integration type safety
|
@wrslatz @riley-kohler aside from the Git options little rework (lmk what you think), the rest of comments have been addressed 👍 Thanks for taking the time to review! |
refactor: type GitHub user profile directly
wrslatz
left a comment
There was a problem hiding this comment.
Thanks for addressing feedback!
riley-kohler
left a comment
There was a problem hiding this comment.
I haven't read through everything yet but running the code gives me a "Failed to fetch forks, graphql.paginate is not a function" error. From what I can tell it's due to the way that the paginate plugin is initiated and then overriden in the new src/bot/rest.ts logic.
Signed-off-by: Matteo Bianchi <37507190+mbianchidev@users.noreply.github.com>
Signed-off-by: Matteo Bianchi <37507190+mbianchidev@users.noreply.github.com>
fix: preserve GraphQL pagination for custom endpoints
riley-kohler
left a comment
There was a problem hiding this comment.
Looks good! Thanks for the contribution!

This pull request adds comprehensive support for GitHub Enterprise Cloud with Data Residency (GHE.com) and GitHub Enterprise Server (GHES) by introducing new environment variables for custom GitHub URLs and committer email domains. It updates the authentication, webhook relay, and UI code to use these configurable endpoints throughout the application. Additionally, the documentation is updated to guide users on integrating with GHE.com and GHES, and some default behaviors and chunk sizes are improved.
Support for GitHub Enterprise (GHE.com/Server) configuration:
GITHUB_SERVER_URL,GITHUB_API_URL,GITHUB_GRAPHQL_URL,GITHUB_USER_EMAIL_DOMAIN) with sensible defaults and documentation to enable seamless integration with GHE.com and GHES instances. (.env.example,env.mjs,README.md,docs/developing.md)src/app/api/auth/lib/nextauth-options.ts)Webhook relay and API usage improvements:
scripts/webhook-relay.mjs)UI and context updates for custom GitHub URLs:
src/app/[organizationId]/page.tsx,src/app/components/dialog/CreateMirrorDialog.tsx,src/app/components/dialog/EditMirrorDialog.tsx)Documentation and configuration enhancements:
README.md,docs/developing.md)