Skip to content

Fix hardcoded github.com references in repo-memory for GitHub Enterprise support#16154

Merged
pelikhan merged 4 commits intomainfrom
copilot/fix-github-enterprise-url-issue
Feb 16, 2026
Merged

Fix hardcoded github.com references in repo-memory for GitHub Enterprise support#16154
pelikhan merged 4 commits intomainfrom
copilot/fix-github-enterprise-url-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 16, 2026

Fix hardcoded github.com references in repo-memory for GitHub Enterprise support

This PR fixes hardcoded github.com references in the repo-memory feature to support GitHub Enterprise (GHE) environments.

Changes Made

  1. actions/setup/js/push_repo_memory.cjs:

    • Added GITHUB_SERVER_URL environment variable support
    • Extract server host dynamically: const serverHost = githubServerUrl.replace(/^https?:\/\//, "");
    • Updated all git URL constructions to use dynamic host instead of hardcoded github.com
  2. actions/setup/sh/clone_repo_memory_branch.sh:

    • Added GITHUB_SERVER_URL parameter to script documentation
    • Extract server host from environment variable with fallback to github.com
    • Updated git clone and remote URL constructions to use dynamic host
  3. pkg/workflow/repo_memory.go:

    • Added GITHUB_SERVER_URL: ${{ github.server_url }} to clone step environment
    • Added server URL extraction in push steps: SERVER_HOST="${GITHUB_SERVER_URL#https://}"
    • Updated generated git pull and push commands to use ${SERVER_HOST} variable
  4. pkg/workflow/repo_memory_integration_test.go:

    • Added TestRepoMemoryGitHubEnterpriseSupport test to verify GHE compatibility
    • Verifies GITHUB_SERVER_URL is passed to clone and push steps
    • Ensures no hardcoded @github.com URLs in generated workflows

Testing

  • ✅ All existing tests pass (including repo-memory specific tests)
  • ✅ New integration test verifies GHE URL handling
  • ✅ Formatting checks pass
  • ✅ Verified generated workflows use dynamic server URL

Impact

  • GitHub.com users: No change in behavior
  • GitHub Enterprise users: Workflows now correctly use GHE instance URLs for repo-memory operations
  • Prevents: Authentication failures and DNS resolution errors on GHE instances

Background

The issue was that repo-memory git operations (clone, fetch, pull, push) hardcoded github.com as 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_URL environment variable (${{ github.server_url }}), which contains the correct host for both GitHub.com and GitHub Enterprise environments.

Original prompt

This section details on the original issue you should resolve

<issue_title>push_repo_memory.cjs script has hardocoded github.com reference</issue_title>
<issue_description># Problem
fix for the git URL construction in the push_repo_memory.cjs script . Currently, some environments (specifically GitHub Enterprise) fail authentication because:

  1. The git URL is constructed using the token as the username only, whereas GitHub requires the x-access-token: prefix.
  2. The git host is hardcoded to github.com in several places, which fails for Enterprise instances (e.g., mycompany.ghe.com).

Include your agent's analysis and findings

My analysis shows that the push_repo_memory.cjs script (and potentially the repo_memory.go compiler logic) constructs git URLs in the format:
https://<token>@github.com/owner/repo.git or https://x-access-token:<token>@github.com/owner/repo.git

There are two major issues for GitHub Enterprise (GHE) users:

  1. Missing user prefix: GitHub's authentication mechanism for tokens requires the format https://x-access-token:<token>@host/.... Without the x-access-token: prefix, the server interprets the token as a username and expects a password, leading to Authentication failed.
  2. Hardcoded host: Several built-in scripts and compiler templates hardcode github.com as the git host. For GHE instances, this means the git commands attempt to connect to the wrong server, or fail because the token provided is not valid for github.com.

Found affected locations:

  • actions/setup/js/push_repo_memory.cjs: Hardcoded github.com in repoUrl construction.
  • pkg/workflow/repo_memory.go: Hardcoded github.com in generated git push/pull commands.
  • pkg/workflow/yaml_generation.go: The "Configure Git credentials" step exists but may not fully catch hardcoded URLs in external scripts if the insteadOf rule is too specific.

Explain the use case and expected behavior

Use Case:
Running gh-aw workflows in a GitHub Enterprise environment that utilize repo-memory or other features requiring git pushes back to the repository.

Expected Behavior:
The workflows should dynamically use the current GitHub host (from github.server_url) and properly formatted authentication credentials (x-access-token:<token>).

Actual Behavior:
Git operations fail on GHE with Authentication failed or Could not resolve host: github.com.

Provide examples if applicable and proposal how to fix it

Example of failure on GHE:

// push_repo_memory.cjs
const repoUrl = `https://x-access-token:${ghToken}@github.com/${targetRepo}.git`;
// On GHE, this should be:
// const repoUrl = `https://x-access-token:${ghToken}@${serverHost}/${targetRepo}.git`;

Proposed Fix:

The fix involves updating the "Configure Git credentials" step in the compiler to add robust insteadOf rewrites that catch both malformed URLs and hardcoded github.com hosts on Enterprise instances.

Updated "Configure Git credentials" implementation:

# In pkg/workflow/yaml_generation.go
git config --global url."https://x-access-token:${GIT_TOKEN}@${SERVER_URL#https://}/".insteadOf "https://${GIT_TOKEN}@github.com/"
git config --global url."https://x-access-token:${GIT_TOKEN}@${SERVER_URL#https://}/".insteadOf "https://x-access-token:${GIT_TOKEN}@github.com/"
git config --global url."https://x-access-token:${GIT_TOKEN}@${SERVER_URL#https://}/".insteadOf "https://${GIT_TOKEN}@${SERVER_URL#https://}/"

This triple-layer rewrite ensures that:

  1. https://<token>@github.com/ -> https://x-access-token:<token>@GHE_HOST/
  2. https://x-access-token:<token>@github.com/ -> https://x-access-token:<token>@GHE_HOST/
  3. https://<token>@GHE_HOST/ -> https://x-access-token:<token>@GHE_HOST/

Additionally, built-in scripts should be updated to use GITHUB_SERVER_URL when available instead of hardcoding github.com.
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ 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

  • Type: patch
  • Description: Fix repo-memory git URLs to respect the active GitHub host so GHE workflows use the configured server provided by GITHUB_SERVER_URL.

Generated by Changeset Generator

- 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://}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot echo value

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
Copy link
Contributor

@copilot keep working

@pelikhan
Copy link
Contributor

@copilot keep working

Copy link
Contributor Author

Copilot AI commented Feb 16, 2026

@copilot keep working

Completed the remaining tasks:

✅ Added integration test TestRepoMemoryGitHubEnterpriseSupport to verify GHE URL format
✅ Ran full unit test suite - all tests pass
✅ Ran formatting checks - all code properly formatted

All repo-memory git operations now use GITHUB_SERVER_URL dynamically, supporting both github.com and GitHub Enterprise instances. See commit bdee432.

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:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh repo view --json owner,name --jq .owner.login &#43; &#34;/&#34; &#43; .name x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh repo view --json owner,name --jq .owner.login &#43; &#34;/&#34; &#43; .name 64/pkg/tool/linux_amd64/vet ignore (http block)
    • Triggering command: /usr/bin/gh gh repo view --json owner,name --jq .owner.login &#43; &#34;/&#34; &#43; .name 64/pkg/tool/linux_amd64/vet nore (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha ithub-script/git/ref/tags/v8 /tmp/go-build3902637341/b212/vet.cfg 0/x64/bin/node ath ../../../.prgit (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha se 2637341/b034/vet.cfg .cfg (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha -unreachable=false /tmp/go-build3902637341/b089/vet.cfg 2637341/b270/vet.cfg (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha t0 -buildtags (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha user.name Test User /usr/bin/git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha 2477109772/.github/workflows .cfg 64/pkg/tool/linux_amd64/vet credential.helpeinfocmp (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha bility_SameInputSameOutput3518405898/001/stability-test.md -importcfg clusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle -s -w -buildmode=exe git -C /tmp/gh-aw-test-runs/20260216-184238-10626/test-3720666954/.github/workflows rev-parse /usr/bin/git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha /home/REDACTED/work/gh-aw/gh-aw/.github/workflows/agent-performance-analyzer.md x_amd64/vet /usr/bin/git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha -c=4 -nolocalimports -importcfg /tmp/go-build3902637341/b402/importcfg -pack /home/REDACTED/work/gh-aw/gh-aw/pkg/repoutil/repoutil.go /home/REDACTED/work/gh-aw/gh-aw/pkg/repoutil/repoutil_test.go ules�� (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha json&#39; --ignore-path ../../../.pr**/*.json (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha UGHoYtrm6 /tmp/go-build3902637341/b065/vet.cfg ache/go/1.25.0/x64/pkg/tool/linux_amd64/compile (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha -unreachable=false /tmp/go-build3902637341/b093/vet.cfg /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 ew@v1.1.1/spew/common.go x_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha ting Go code...&#34; .cfg 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion ignore (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo (http block)
    • Triggering command: /usr/bin/gh gh workflow list --repo owner/repo --json name,path,state 64/pkg/tool/linux_amd64/vet nore (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name (http block)
  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login js/**/*.json&#39; ---p (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login js/**/*.json&#39; --ignore-path ../../../.prettierignore (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix hardcoded GitHub reference in push_repo_memory.cjs Fix hardcoded github.com references in repo-memory for GitHub Enterprise support Feb 16, 2026
@pelikhan pelikhan added the smoke label Feb 16, 2026
@github-actions
Copy link
Contributor

🧪 Smoke Project is now testing project operations...

@github-actions
Copy link
Contributor

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2026

Smoke Copilot SDK failed. Please review the logs for details.

@github-actions
Copy link
Contributor

🧪 Smoke Temporary ID is now testing temporary ID functionality...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@pelikhan pelikhan marked this pull request as ready for review February 16, 2026 18:48
Copilot AI review requested due to automatic review settings February 16, 2026 18:48
@github-actions
Copy link
Contributor

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.52.0
jq 1.7
yq 4.52.2
curl 8.5.0
gh 2.86.0
node 20.20.0
python3 3.12.3
go 1.24.13
java (available)
dotnet 10.0.102

Result: 12/12 tools available ✅

All required development tools are present and functional in the agent container environment.

🔧 Tool validation by Agent Container Smoke Test for issue #16154

@github-actions
Copy link
Contributor

Smoke Temporary ID completed successfully. Temporary ID validation passed.

@github-actions
Copy link
Contributor

Smoke Project completed successfully. All project operations validated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_URL environment 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?:\/\//, "");
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +350 to +353
// 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")
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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")

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

🎭 The smoke test agent stopped by!

Beep boop! Just finished running validation tests on workflow run §22074209751. Everything's looking smooth!

✨ All systems operational! ✨

📰 BREAKING: Report filed by Smoke Copilot for issue #16154

@github-actions
Copy link
Contributor

PR titles: Add .NET/C# instructions to multi-language workflows; Stabilize import topological sort and add comprehensive test coverage
GitHub MCP: ✅
Serena MCP: ✅
Playwright: ✅
File write+cat: ✅
Build: ✅
Overall: PASS

🔮 The oracle has spoken through Smoke Codex for issue #16154

@github-actions
Copy link
Contributor

Smoke Test Results

PRs: #16155, #16172
CLI: #16172, #16169

Test Status
GitHub MCP
Safe Inputs GH
Playwright
File Writing
Bash Tool
Discussion Query
Build gh-aw
Discussion Create
Workflow Dispatch
PR Review

Overall: PASS

@Copilot @pelikhan

📰 BREAKING: Report filed by Smoke Copilot for issue #16154

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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://}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good defensive programming - handling both https:// and `(redacted) prefix removal. The double substitution ensures compatibility with different server URL formats.

@github-actions
Copy link
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@pelikhan pelikhan merged commit 425869f into main Feb 16, 2026
1 check passed
@pelikhan pelikhan deleted the copilot/fix-github-enterprise-url-issue branch February 16, 2026 18:52
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💥 Automated smoke test review - all systems nominal!

💥 [THE END] — Illustrated by Smoke Claude for issue #16154

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

push_repo_memory.cjs script has hardocoded github.com reference

2 participants