Fix add-wizard/add --create-pull-request failing on GitHub Enterprise Server repos#20898
Merged
Fix add-wizard/add --create-pull-request failing on GitHub Enterprise Server repos#20898
Conversation
When adding a workflow with --create-pull-request in a repo whose origin points to GitHub Enterprise Server, detect the host from the git remote URL and pass --hostname to gh pr create, so the PR is created on the correct GHES instance instead of always defaulting to github.com. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
pelikhan
March 14, 2026 02:36
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes add-wizard / add --create-pull-request PR creation against GitHub Enterprise Server by deriving the host from remote.origin.url and passing it through to gh invocations.
Changes:
- Add git-remote host extraction helpers (
extractHostFromRemoteURL,getHostFromOriginRemote). - Update PR creation flow to add
--hostname <host>togh repo viewandgh pr createwhen the origin remote is notgithub.com. - Add unit tests for URL parsing and an integration-style test that reads
remote.origin.urlfrom a temp git repo.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
pkg/cli/git.go |
Adds helpers to derive host from remote.origin.url. |
pkg/cli/pr_command.go |
Uses derived host to route gh commands to GHES via --hostname. |
pkg/cli/git_test.go |
Adds tests for host parsing and origin-remote host detection. |
.changeset/patch-fix-ghes-pr-creation.md |
Documents the fix as a patch changeset. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
github-actions bot
added a commit
that referenced
this pull request
Mar 14, 2026
… configuration Expand the GitHub Enterprise Server Support section in the CLI reference to cover two improvements merged on 2026-03-14: - Commands with --create-pull-request (add, add-wizard, init, update, upgrade) now automatically detect the enterprise host from the git remote and route PR creation to the correct GHES instance (from #20898) - The bundled configure_gh_for_ghe.sh helper script is now available at /opt/gh-aw/actions/ for workflows that use custom steps with gh CLI on GHES. Includes a usage example and note about automatic GITHUB_SERVER_URL detection (from #20878) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Mar 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gh pr create --repo owner/repowithout--hostnamealways routes to github.com, so PR creation fails with a repository-not-found GraphQL error when the git remote points to a GHES instance.Changes
pkg/cli/git.go: AddedextractHostFromRemoteURL(url)— parses the hostname from any git remote URL format (HTTPS, HTTP, SSH scp-likegit@host:path, SSH URLssh://[user@]host/path), defaulting togithub.comon failure. AddedgetHostFromOriginRemote()— readsremote.origin.urlvia git config and returns its hostname.pkg/cli/pr_command.go:createPR()now callsgetHostFromOriginRemote()and appends--hostname <host>to both thegh repo viewandgh pr createinvocations when the remote host is notgithub.com.pkg/cli/git_test.go: Table-driven tests forextractHostFromRemoteURL(HTTPS, SSH, SSH URL, port, edge cases) and integration tests forgetHostFromOriginRemoteagainst a real temp git repo.