Skip to content

feat: Add support for GHE / Data Residency#480

Open
mbianchidev wants to merge 7 commits into
github-community-projects:mainfrom
mbianchidev:main
Open

feat: Add support for GHE / Data Residency#480
mbianchidev wants to merge 7 commits into
github-community-projects:mainfrom
mbianchidev:main

Conversation

@mbianchidev
Copy link
Copy Markdown

This pull request adds comprehensive support for GitHub Enterprise Cloud with Data Residency (*.ghe.com) and GitHub Enterprise Server (GHES) deployments that do not use GitHub connect.

It introduces new environment variables for configuring GitHub server and API URLs, ensures these variables are available both server- and client-side, and updates the codebase to use these variables throughout authentication, API requests, UI links, and webhook relays. Documentation is also updated to guide users on configuring and building the app for GHE.com and GHES.

Enterprise GitHub configuration support:

  • Added new environment variables (GITHUB_SERVER_URL, GITHUB_API_URL, NEXT_PUBLIC_GITHUB_SERVER_URL, NEXT_PUBLIC_GITHUB_API_URL, GITHUB_USER_EMAIL_DOMAIN) in .env.example and documented their usage for GHE.com and GHES in README.md and docs/developing.md.
  • Updated environment variable validation and exposure in env.mjs to support the new variables, ensuring they are available both server- and client-side.

Authentication and API integration:

  • Refactored authentication logic in nextauth-options.ts to use the configured GitHub server/API URLs for OAuth endpoints and user info, overriding defaults to support GHE.com/GHES.
  • Updated the bot and webhook relay scripts to use the derived or configured API URLs, ensuring compatibility with GHE.com/GHES API endpoints.

UI and UX improvements:

  • Replaced hardcoded github.com links in UI components with dynamic links based on the configured GitHub server URL, ensuring correct navigation for all deployments.

These changes make the app robust and configurable for both public GitHub and enterprise GitHub deployments, improving flexibility and user experience across different hosting scenarios.

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
Author

@wrslatz it should be ready for review 👍

@wrslatz wrslatz requested review from Miablo, ahpook and riley-kohler May 29, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants