Skip to content

feat: Add support for GHE / Data Residency and GHES - #480

Merged
wrslatz merged 27 commits into
github-community-projects:mainfrom
mbianchidev:main
Aug 26, 2026
Merged

feat: Add support for GHE / Data Residency and GHES#480
wrslatz merged 27 commits into
github-community-projects:mainfrom
mbianchidev:main

Conversation

@mbianchidev

@mbianchidev mbianchidev commented May 28, 2026

Copy link
Copy Markdown
Contributor

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:

  • Added new environment variables (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)
  • Updated authentication logic to use the configured GitHub endpoints for OAuth flows, token refresh, user info, and organization membership checks, ensuring compatibility with custom GitHub deployments. (src/app/api/auth/lib/nextauth-options.ts)

Webhook relay and API usage improvements:

  • Updated the webhook relay script to use the configured GitHub API base URL and improved handling of environment variables, making it compatible with GHE.com/GHES and more robust in local and Docker environments. (scripts/webhook-relay.mjs)

UI and context updates for custom GitHub URLs:

  • Modified UI components to use the configured GitHub server URL for all links to repositories and forks, ensuring correct navigation regardless of the GitHub environment. (src/app/[organizationId]/page.tsx, src/app/components/dialog/CreateMirrorDialog.tsx, src/app/components/dialog/EditMirrorDialog.tsx)

Documentation and configuration enhancements:

  • Added detailed documentation for GHE.com and GHES setup, clarified environment variable usage, and improved developer guidance for building and deploying in enterprise environments. (README.md, docs/developing.md)

mbianchidev and others added 2 commits May 28, 2026 17:44
…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>
@mbianchidev
mbianchidev marked this pull request as ready for review May 29, 2026 15:08
@mbianchidev
mbianchidev requested review from a team as code owners May 29, 2026 15:08
@mbianchidev mbianchidev changed the title WIP: Add support for GHE / Data Residency feat: Add support for GHE / Data Residency May 29, 2026
@mbianchidev

Copy link
Copy Markdown
Contributor Author

@wrslatz it should be ready for review 👍

@wrslatz
wrslatz requested review from Miablo, ahpook and riley-kohler May 29, 2026 15:35

@riley-kohler riley-kohler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/pages/api/webhooks.ts Outdated
Copilot AI and others added 5 commits June 16, 2026 16:06
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
@wrslatz
wrslatz requested a review from riley-kohler August 6, 2026 04:10

@wrslatz wrslatz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ❤️

Comment thread src/app/api/auth/lib/nextauth-options.ts Outdated
Comment thread src/bot/rest.ts Outdated
Comment thread src/pages/api/webhooks.ts Outdated
Comment thread src/pages/api/webhooks.ts Outdated
Comment thread src/server/git/controller.ts Outdated
Comment thread test/docs/docker-build-config.test.ts
@mbianchidev

Copy link
Copy Markdown
Contributor Author

@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!

Comment thread src/app/api/auth/lib/nextauth-options.ts Outdated
refactor: type GitHub user profile directly

@wrslatz wrslatz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing feedback!

@wrslatz
wrslatz requested review from riley-kohler and removed request for riley-kohler August 23, 2026 16:14

@riley-kohler riley-kohler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/bot/rest.ts Outdated
Copilot AI and others added 5 commits August 25, 2026 07:49
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
@mbianchidev

mbianchidev commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

working to get a GHES instance to test it end to end locally

Edit:
image

Test is 🟢

@riley-kohler riley-kohler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for the contribution!

@mbianchidev mbianchidev changed the title feat: Add support for GHE / Data Residency feat: Add support for GHE / Data Residency and GHES Aug 25, 2026

@wrslatz wrslatz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@wrslatz
wrslatz merged commit 03e45b2 into github-community-projects:main Aug 26, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add GitHub Enterprise Server (GHE.com / Data Residency) support

4 participants