diff --git a/pkg/cli/add_interactive_orchestrator.go b/pkg/cli/add_interactive_orchestrator.go index b9f50107d7..73090e372a 100644 --- a/pkg/cli/add_interactive_orchestrator.go +++ b/pkg/cli/add_interactive_orchestrator.go @@ -57,6 +57,18 @@ func RunAddInteractive(ctx context.Context, workflowSpecs []string, verbose bool return errors.New("interactive add cannot be used in automated tests or CI environments") } + // Auto-detect GHES host from git remote if not already set + if os.Getenv("GH_HOST") == "" { + detectedHost := getHostFromOriginRemote() + if detectedHost != "github.com" { + addInteractiveLog.Printf("Auto-detected GHES host from git remote: %s", detectedHost) + os.Setenv("GH_HOST", detectedHost) + if verbose { + fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Auto-detected GitHub Enterprise host: "+detectedHost)) + } + } + } + config := &AddInteractiveConfig{ WorkflowSpecs: workflowSpecs, Verbose: verbose, diff --git a/pkg/cli/audit.go b/pkg/cli/audit.go index bb29486978..3f23917e0a 100644 --- a/pkg/cli/audit.go +++ b/pkg/cli/audit.go @@ -133,7 +133,15 @@ func isPermissionError(err error) bool { // If jobID is provided (>0), focuses audit on that specific job // If stepNumber is provided (>0), extracts output for that specific step func AuditWorkflowRun(ctx context.Context, runID int64, owner, repo, hostname string, outputDir string, verbose bool, parse bool, jsonOutput bool, jobID int64, stepNumber int) error { - auditLog.Printf("Starting audit for workflow run: runID=%d, owner=%s, repo=%s, jobID=%d, stepNumber=%d", runID, owner, repo, jobID, stepNumber) + // Auto-detect GHES host from git remote if hostname is not provided + if hostname == "" { + hostname = getHostFromOriginRemote() + if hostname != "github.com" { + auditLog.Printf("Auto-detected GHES host from git remote: %s", hostname) + } + } + + auditLog.Printf("Starting audit for workflow run: runID=%d, owner=%s, repo=%s, hostname=%s, jobID=%d, stepNumber=%d", runID, owner, repo, hostname, jobID, stepNumber) // Check context cancellation at the start select { @@ -433,7 +441,15 @@ func AuditWorkflowRun(ctx context.Context, runID int64, owner, repo, hostname st // auditJobRun performs a targeted audit of a specific job within a workflow run // If stepNumber > 0, focuses on extracting output for that specific step func auditJobRun(runID int64, jobID int64, stepNumber int, owner, repo, hostname string, outputDir string, verbose bool, jsonOutput bool) error { - auditLog.Printf("Starting job-specific audit: runID=%d, jobID=%d, stepNumber=%d", runID, jobID, stepNumber) + // Auto-detect GHES host from git remote if hostname is not provided + if hostname == "" { + hostname = getHostFromOriginRemote() + if hostname != "github.com" { + auditLog.Printf("Auto-detected GHES host from git remote: %s", hostname) + } + } + + auditLog.Printf("Starting job-specific audit: runID=%d, jobID=%d, stepNumber=%d, hostname=%s", runID, jobID, stepNumber, hostname) // Create output directory for job-specific artifacts if err := os.MkdirAll(outputDir, 0750); err != nil {