From 50cc4a66e579fbd7ac5e6b755283c45d0034a1ca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 01:07:39 +0000 Subject: [PATCH 1/3] Plan GHES init detection fix Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/skills/agentic-workflows/SKILL.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/skills/agentic-workflows/SKILL.md b/.github/skills/agentic-workflows/SKILL.md index d0c9af823a8..3af44da06f2 100644 --- a/.github/skills/agentic-workflows/SKILL.md +++ b/.github/skills/agentic-workflows/SKILL.md @@ -41,6 +41,7 @@ Load these files from `github/gh-aw` (they are not available locally). - `.github/aw/github-mcp-server-pagination.md` - `.github/aw/github-mcp-server.md` - `.github/aw/instructions.md` +- `.github/aw/jobs.md` - `.github/aw/linter-workflows.md` - `.github/aw/llms.md` - `.github/aw/loop.md` From f10c177ae2e81d99dc78f9b1b778ca6e70365161 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 01:10:34 +0000 Subject: [PATCH 2/3] Skip GHES detection during CI init Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/workflows/aw.json | 1 - pkg/cli/init.go | 10 +++++++++- pkg/cli/init_test.go | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/.github/workflows/aw.json b/.github/workflows/aw.json index 283aa66983b..42ecbaedad6 100644 --- a/.github/workflows/aw.json +++ b/.github/workflows/aw.json @@ -1,6 +1,5 @@ { "auto_upgrade": { "cron": "0 9 * * 1" }, - "ghes": false, "maintenance": { "action_failure_issue_expires": 12, "label_triggers": true diff --git a/pkg/cli/init.go b/pkg/cli/init.go index be1ec55823d..2c143cde98f 100644 --- a/pkg/cli/init.go +++ b/pkg/cli/init.go @@ -65,7 +65,10 @@ func InitRepository(opts InitOptions) error { initLog.Print("Verified git repository") // Auto-detect GHES deployment and configure aw.json ghes: true when needed. - if _, err := ensureGHESRepoConfig(opts.Verbose); err != nil { + // Skip detection in CI, where gh-proxy can make the environment look like GHES. + if IsRunningInCI() { + initLog.Print("Running in CI, skipping GHES deployment detection") + } else if _, err := ensureGHESRepoConfig(opts.Verbose); err != nil { initLog.Printf("Failed to configure GHES repo config: %v", err) // Non-fatal: continue with the rest of init fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to configure GHES repo config: %v", err))) @@ -368,6 +371,11 @@ func detectGHESDeployment() string { // if GHES is not detected or if "ghes": true is already present. // Returns (updated bool, err). func ensureGHESRepoConfig(verbose bool) (bool, error) { + if IsRunningInCI() { + initLog.Print("Running in CI, skipping GHES repo configuration") + return false, nil + } + ghesHost := detectGHESDeployment() if ghesHost == "" { initLog.Print("No GHES deployment detected, skipping aw.json ghes configuration") diff --git a/pkg/cli/init_test.go b/pkg/cli/init_test.go index a9b891b77da..7927ac7147a 100644 --- a/pkg/cli/init_test.go +++ b/pkg/cli/init_test.go @@ -431,6 +431,7 @@ func TestEnsureGHESRepoConfig_GHHostEnvVar(t *testing.T) { } // Point GH_HOST at a GHES instance + clearCIEnvironment(t) t.Setenv("GH_HOST", "ghes.example.com") t.Setenv("GITHUB_SERVER_URL", "") @@ -471,6 +472,7 @@ func TestEnsureGHESRepoConfig_Idempotent(t *testing.T) { t.Fatalf("git init failed: %v", err) } + clearCIEnvironment(t) t.Setenv("GH_HOST", "ghes.example.com") t.Setenv("GITHUB_SERVER_URL", "") @@ -492,3 +494,41 @@ func TestEnsureGHESRepoConfig_Idempotent(t *testing.T) { t.Error("Second call should be idempotent (no update when ghes: true already set)") } } + +func TestEnsureGHESRepoConfig_SkipsCI(t *testing.T) { + tempDir := t.TempDir() + oldWd, err := os.Getwd() + if err != nil { + t.Fatalf("Failed to get cwd: %v", err) + } + defer func() { _ = os.Chdir(oldWd) }() + if err := os.Chdir(tempDir); err != nil { + t.Fatalf("Failed to chdir: %v", err) + } + + if err := exec.Command("git", "init").Run(); err != nil { + t.Fatalf("git init failed: %v", err) + } + + t.Setenv("CI", "true") + t.Setenv("GH_HOST", "ghes.example.com") + + updated, err := ensureGHESRepoConfig(false) + if err != nil { + t.Fatalf("ensureGHESRepoConfig returned unexpected error: %v", err) + } + if updated { + t.Fatal("ensureGHESRepoConfig should skip GHES configuration in CI") + } + + if _, err := os.Stat(filepath.Join(tempDir, ".github", "workflows", "aw.json")); !os.IsNotExist(err) { + t.Fatal("ensureGHESRepoConfig should not create aw.json in CI") + } +} + +func clearCIEnvironment(t *testing.T) { + t.Helper() + for _, envVar := range []string{"CI", "CONTINUOUS_INTEGRATION", "GITHUB_ACTIONS", "COPILOT_AGENT_SESSION_ID"} { + t.Setenv(envVar, "") + } +} From 37c0ab6352a3c0ffa51c4c837ded658fd233bd4a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 01:12:45 +0000 Subject: [PATCH 3/3] Centralize CI GHES detection guard Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/init.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/cli/init.go b/pkg/cli/init.go index 2c143cde98f..90fea41ed9a 100644 --- a/pkg/cli/init.go +++ b/pkg/cli/init.go @@ -65,10 +65,8 @@ func InitRepository(opts InitOptions) error { initLog.Print("Verified git repository") // Auto-detect GHES deployment and configure aw.json ghes: true when needed. - // Skip detection in CI, where gh-proxy can make the environment look like GHES. - if IsRunningInCI() { - initLog.Print("Running in CI, skipping GHES deployment detection") - } else if _, err := ensureGHESRepoConfig(opts.Verbose); err != nil { + // ensureGHESRepoConfig skips detection in CI, where gh-proxy can make the environment look like GHES. + if _, err := ensureGHESRepoConfig(opts.Verbose); err != nil { initLog.Printf("Failed to configure GHES repo config: %v", err) // Non-fatal: continue with the rest of init fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to configure GHES repo config: %v", err)))