Skip to content

feat(github): add GitHub Enterprise Server support to GitHub Action - #13860

Open
balcsida wants to merge 25 commits into
anomalyco:devfrom
balcsida:feat/ghes-support
Open

feat(github): add GitHub Enterprise Server support to GitHub Action#13860
balcsida wants to merge 25 commits into
anomalyco:devfrom
balcsida:feat/ghes-support

Conversation

@balcsida

@balcsida balcsida commented Feb 16, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes #12830

The GitHub Action hardcodes github.com URLs everywhere, so it can't run on GHES. This PR reads GITHUB_SERVER_URL and GITHUB_API_URL env vars (set automatically by GHES runners) and uses them to derive all host-specific values — Octokit/GraphQL baseUrl, git credential config keys, noreply emails, fork remote URLs, image attachment regexes, and the token revocation endpoint. Defaults to github.com when the env vars aren't set, so nothing changes for existing users.

Also adds a parseGitRemote function (host-agnostic version of parseGitHubRemote) so the install command detects GHES remotes and generates a workflow with use_github_token: true and write permissions pre-configured.

How did you verify your code works?

  • Both files transpile cleanly with bun build --no-bundle
  • All 38 existing + new tests pass (bun test test/cli/github-remote.test.ts and github-action.test.ts)
  • New tests cover parseGitRemote with GHES URLs, SSH, HTTPS, various hosts
  • Verified no remaining hardcoded github.com references that should be parameterized (only defaults, comments, and the opencode app URL which correctly stays on github.com)

@neronlux

Copy link
Copy Markdown

Great request to allow use in Enterprise

@balcsida balcsida changed the title feat(github): add GitHub Enterprise Server support to GitHub Action feat: add GitHub Enterprise Server support to GitHub Action Feb 16, 2026
@balcsida balcsida changed the title feat: add GitHub Enterprise Server support to GitHub Action feat(github): add GitHub Enterprise Server support to GitHub Action Feb 16, 2026
@balcsida
balcsida force-pushed the feat/ghes-support branch from ccda103 to 584ced7 Compare March 19, 2026 09:08
@balcsida
balcsida requested a review from adamdotdevin as a code owner March 19, 2026 09:08
@balcsida
balcsida force-pushed the feat/ghes-support branch from 584ced7 to 46ee5df Compare March 19, 2026 09:14
@balcsida
balcsida force-pushed the feat/ghes-support branch from 46ee5df to 37135c8 Compare April 4, 2026 22:24
@entl

entl commented May 8, 2026

Copy link
Copy Markdown

Are there any plans to merge this feature? It would be very helpful for GitHub Enterprise Server users.

@balcsida
balcsida force-pushed the feat/ghes-support branch from 37135c8 to 60ed96e Compare May 19, 2026 19:01
@balcsida
balcsida force-pushed the feat/ghes-support branch from 60ed96e to f743f30 Compare May 27, 2026 07:04
@balcsida
balcsida force-pushed the feat/ghes-support branch from f743f30 to 705f1f5 Compare July 2, 2026 18:12
@rover0811

Copy link
Copy Markdown

Thanks for working on GHES support. I reproduced the current failure with OpenCode 1.18.9 and the pinned official GitHub Action on a GHES runner. The runner provides an internal GITHUB_API_URL, but github.handler.ts constructs Octokit without a baseUrl, so the GHES token is sent to api.github.com and the run fails with 401 Bad credentials.

This PR addresses that REST failure, but I noticed the GraphQL client currently receives ghUrls.apiUrl as its baseUrl. On GHES, GITHUB_API_URL normally ends in /api/v3. @octokit/graphql appends /graphql and documents the GHES baseUrl as https://host/api, so using the REST URL would target /api/v3/graphql instead of the GHES endpoint /api/graphql. GitHub Actions also provides GITHUB_GRAPHQL_URL.

Could getGitHubURLs return a separate GraphQL base URL, using GITHUB_GRAPHQL_URL with the trailing /graphql removed, and fall back to serverUrl + /api for GHES? A focused request-mocking test that asserts the final REST and GraphQL URLs would also catch this distinction.

I can validate an updated branch against the GHES dry-run that exposed the 401. I have omitted the private host and credentials from this report.

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.

PR agent for Github enterprise server

5 participants