Fix hardcoded github.com references in repo-memory for GitHub Enterprise support#16154
Fix hardcoded github.com references in repo-memory for GitHub Enterprise support#16154
Conversation
- Updated push_repo_memory.cjs to use GITHUB_SERVER_URL environment variable - Updated clone_repo_memory_branch.sh to use dynamic server URL - Updated repo_memory.go to pass GITHUB_SERVER_URL and use dynamic SERVER_HOST variable - All repo-memory git operations now support GitHub Enterprise instances Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
|
||
| # Extract host from server URL (remove https:// or http:// prefix) | ||
| SERVER_HOST="${GITHUB_SERVER_URL#https://}" | ||
| SERVER_HOST="${SERVER_HOST#http://}" |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot keep working |
|
@copilot keep working |
Completed the remaining tasks: ✅ Added integration test All repo-memory git operations now use Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
🧪 Smoke Project is now testing project operations... |
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
|
❌ Smoke Copilot SDK failed. Please review the logs for details. |
|
🧪 Smoke Temporary ID is now testing temporary ID functionality... |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
Agent Container Tool Check
Result: 12/12 tools available ✅ All required development tools are present and functional in the agent container environment.
|
|
✅ Smoke Temporary ID completed successfully. Temporary ID validation passed. |
|
✅ Smoke Project completed successfully. All project operations validated. |
There was a problem hiding this comment.
Pull request overview
This PR fixes hardcoded github.com references in the repo-memory feature to support GitHub Enterprise (GHE) environments. The changes ensure that git operations dynamically use the correct server URL from ${{ github.server_url }} instead of hardcoded values.
Changes:
- Added
GITHUB_SERVER_URLenvironment variable support across all repo-memory git operations - Updated git URL constructions to use dynamic server host extraction instead of hardcoded
github.com - Added integration test to verify GHE compatibility and prevent regression
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/repo_memory.go |
Added GITHUB_SERVER_URL to clone and push steps, updated git pull/push commands to use dynamic ${SERVER_HOST} variable |
actions/setup/sh/clone_repo_memory_branch.sh |
Added server URL extraction with fallback to github.com, updated git clone and remote URL constructions |
actions/setup/js/push_repo_memory.cjs |
Added dynamic server host extraction from GITHUB_SERVER_URL, updated all git URL constructions |
pkg/workflow/repo_memory_integration_test.go |
Added new test to verify GITHUB_SERVER_URL is passed to steps and hardcoded URLs are not present |
.github/workflows/audit-workflows.lock.yml |
Regenerated workflow with GITHUB_SERVER_URL environment variables |
.github/workflows/agent-performance-analyzer.lock.yml |
Regenerated workflow with GITHUB_SERVER_URL environment variables |
.changeset/patch-repo-memory-ghe.md |
Added changeset documenting the fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try { | ||
| const repoUrl = `https://x-access-token:${ghToken}@github.com/${targetRepo}.git`; | ||
| // Extract host from server URL (remove https:// prefix) | ||
| const serverHost = githubServerUrl.replace(/^https?:\/\//, ""); |
There was a problem hiding this comment.
The serverHost extraction logic is duplicated three times in this file (lines 136, 349, and 361). Consider extracting this to a helper function at the top of the file to avoid code duplication and improve maintainability.
| // Check that GITHUB_SERVER_URL is passed to push step (in push_repo_memory job) | ||
| // The push step should include GITHUB_SERVER_URL in the env section | ||
| if !strings.Contains(lockFile, "GITHUB_SERVER_URL: ${{ github.server_url }}") { | ||
| t.Error("Expected GITHUB_SERVER_URL environment variable in push step") |
There was a problem hiding this comment.
The test checks for GITHUB_SERVER_URL twice with identical conditions (lines 346 and 352), which doesn't distinguish between the clone step and push step. Consider making these checks more specific by verifying the context around each occurrence (e.g., checking for nearby step names) to ensure both steps actually have the environment variable set.
| // Check that GITHUB_SERVER_URL is passed to push step (in push_repo_memory job) | |
| // The push step should include GITHUB_SERVER_URL in the env section | |
| if !strings.Contains(lockFile, "GITHUB_SERVER_URL: ${{ github.server_url }}") { | |
| t.Error("Expected GITHUB_SERVER_URL environment variable in push step") | |
| // Check that GITHUB_SERVER_URL is passed to both clone and push steps | |
| // It should appear at least twice (once for the clone step and once for the push step) | |
| if strings.Count(lockFile, "GITHUB_SERVER_URL: ${{ github.server_url }}") < 2 { | |
| t.Error("Expected GITHUB_SERVER_URL environment variable in both clone and push steps") |
|
🎭 The smoke test agent stopped by! Beep boop! Just finished running validation tests on workflow run §22074209751. Everything's looking smooth! ✨ All systems operational! ✨
|
|
PR titles: Add .NET/C# instructions to multi-language workflows; Stabilize import topological sort and add comprehensive test coverage
|
Smoke Test ResultsPRs: #16155, #16172
Overall: PASS ✅
|
There was a problem hiding this comment.
GitHub Enterprise URL support looks solid. The changes correctly parameterize the server URL instead of hardcoding github.com, enabling compatibility with GHE instances. Test coverage validates the implementation.
📰 BREAKING: Report filed by Smoke Copilot for issue #16154
| const githubRunId = process.env.GITHUB_RUN_ID || "unknown"; | ||
| const githubServerUrl = process.env.GITHUB_SERVER_URL || "https://github.com"; | ||
|
|
||
| // Log environment variable configuration for debugging |
There was a problem hiding this comment.
Nice GitHub Enterprise support! Dynamically extracting the server host ensures compatibility with both github.com and GHE instances. 👍
| fi | ||
|
|
||
| # Extract host from server URL (remove https:// or http:// prefix) | ||
| SERVER_HOST="${GITHUB_SERVER_URL#https://}" |
There was a problem hiding this comment.
Good defensive programming - handling both https:// and `(redacted) prefix removal. The double substitution ensures compatibility with different server URL formats.
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
There was a problem hiding this comment.
💥 Automated smoke test review - all systems nominal!
💥 [THE END] — Illustrated by Smoke Claude for issue #16154
Fix hardcoded github.com references in repo-memory for GitHub Enterprise support
This PR fixes hardcoded
github.comreferences in the repo-memory feature to support GitHub Enterprise (GHE) environments.Changes Made
actions/setup/js/push_repo_memory.cjs:GITHUB_SERVER_URLenvironment variable supportconst serverHost = githubServerUrl.replace(/^https?:\/\//, "");github.comactions/setup/sh/clone_repo_memory_branch.sh:GITHUB_SERVER_URLparameter to script documentationgithub.compkg/workflow/repo_memory.go:GITHUB_SERVER_URL: ${{ github.server_url }}to clone step environmentSERVER_HOST="${GITHUB_SERVER_URL#https://}"${SERVER_HOST}variablepkg/workflow/repo_memory_integration_test.go:TestRepoMemoryGitHubEnterpriseSupporttest to verify GHE compatibilityGITHUB_SERVER_URLis passed to clone and push steps@github.comURLs in generated workflowsTesting
Impact
Background
The issue was that repo-memory git operations (clone, fetch, pull, push) hardcoded
github.comas the git host. For GitHub Enterprise instances (e.g.,mycompany.ghe.com), this caused git commands to fail with "Could not resolve host: github.com" or authentication errors.The fix ensures all git URLs are constructed dynamically using the
GITHUB_SERVER_URLenvironment variable (${{ github.server_url }}), which contains the correct host for both GitHub.com and GitHub Enterprise environments.Original prompt
push_repo_memory.cjsscript has hardocoded github.com reference #16150✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Changeset
GITHUB_SERVER_URL.