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` 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..90fea41ed9a 100644 --- a/pkg/cli/init.go +++ b/pkg/cli/init.go @@ -65,6 +65,7 @@ func InitRepository(opts InitOptions) error { initLog.Print("Verified git repository") // Auto-detect GHES deployment and configure aw.json ghes: true when needed. + // 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 @@ -368,6 +369,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, "") + } +}