From 497314a1bcccaf83037be5b9be62e90e4fdb440a Mon Sep 17 00:00:00 2001 From: Don Syme Date: Sun, 22 Mar 2026 23:53:02 +0000 Subject: [PATCH 1/2] fix: pull merged workflow files after GitHub confirms workflow is ready MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, updateLocalBranch() ran immediately after gh pr merge returned. At that point GitHub's git objects may not yet reflect the merged commit, so git fetch + git pull retrieved stale refs and the workflow .md file was missing from the working tree. This caused: ✗ Failed to run workflow: workflow file not found: .github/workflows/repo-assist.md The fix moves updateLocalBranch() to just before RunSpecificWorkflowInteractively is called, inside checkStatusAndOfferRun. By that point the GitHub Actions API has confirmed the workflow is active (workflowFound=true), meaning the merge is fully propagated to GitHub's git layer, so the pull reliably retrieves the new workflow files. --- pkg/cli/add_interactive_git.go | 11 ----------- pkg/cli/add_interactive_workflow.go | 10 ++++++++++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pkg/cli/add_interactive_git.go b/pkg/cli/add_interactive_git.go index fcbf99c998a..dd9f3032f8a 100644 --- a/pkg/cli/add_interactive_git.go +++ b/pkg/cli/add_interactive_git.go @@ -186,17 +186,6 @@ func (c *AddInteractiveConfig) createWorkflowPRAndConfigureSecret(ctx context.Co fmt.Fprintln(os.Stderr, console.FormatSuccessMessage(fmt.Sprintf("Secret '%s' added", secretName))) } - // Step 8d: Update local branch with merged changes from GitHub. - // Switch to the default branch and pull so that workflow files are available - // locally for the subsequent "run workflow" step. - if err := c.updateLocalBranch(); err != nil { - // Non-fatal - warn the user and continue; the workflow exists on GitHub - // even if we can't update the local branch. - addInteractiveLog.Printf("Failed to update local branch: %v", err) - fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Could not update local branch: %v", err))) - fmt.Fprintln(os.Stderr, "You may need to switch to your repository's default branch (for example 'main') and run 'git pull' manually before running the workflow.") - } - return nil } diff --git a/pkg/cli/add_interactive_workflow.go b/pkg/cli/add_interactive_workflow.go index 272dabab501..351a718af1b 100644 --- a/pkg/cli/add_interactive_workflow.go +++ b/pkg/cli/add_interactive_workflow.go @@ -127,6 +127,16 @@ func (c *AddInteractiveConfig) checkStatusAndOfferRun(ctx context.Context) error if parsed != nil { fmt.Fprintln(os.Stderr, "") + // Pull the merged workflow files now that we know GitHub has processed the + // merge (workflowFound is true). Doing this here—rather than immediately + // after the PR merge—avoids a race where git fetch runs before GitHub's git + // objects have been updated, which caused "workflow file not found" errors. + if err := c.updateLocalBranch(); err != nil { + addInteractiveLog.Printf("Failed to update local branch: %v", err) + fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Could not update local branch: %v", err))) + fmt.Fprintln(os.Stderr, "You may need to switch to your repository's default branch (for example 'main') and run 'git pull' manually before running the workflow.") + } + if err := RunSpecificWorkflowInteractively(ctx, parsed.WorkflowName, c.Verbose, c.EngineOverride, c.RepoOverride, "", false, false, false); err != nil { fmt.Fprintln(os.Stderr, console.FormatErrorMessage(fmt.Sprintf("Failed to run workflow: %v", err))) c.showFinalInstructions() From 390927a85996f4b4f971bd2182fc56ff44196878 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Mon, 23 Mar 2026 00:18:35 +0000 Subject: [PATCH 2/2] Update pkg/cli/add_interactive_workflow.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- pkg/cli/add_interactive_workflow.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/cli/add_interactive_workflow.go b/pkg/cli/add_interactive_workflow.go index 351a718af1b..f94d0480cc1 100644 --- a/pkg/cli/add_interactive_workflow.go +++ b/pkg/cli/add_interactive_workflow.go @@ -131,11 +131,17 @@ func (c *AddInteractiveConfig) checkStatusAndOfferRun(ctx context.Context) error // merge (workflowFound is true). Doing this here—rather than immediately // after the PR merge—avoids a race where git fetch runs before GitHub's git // objects have been updated, which caused "workflow file not found" errors. + if !c.Verbose { + fmt.Fprintln(os.Stderr, "Updating local branch (this may take a few seconds)...") + } if err := c.updateLocalBranch(); err != nil { addInteractiveLog.Printf("Failed to update local branch: %v", err) fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Could not update local branch: %v", err))) fmt.Fprintln(os.Stderr, "You may need to switch to your repository's default branch (for example 'main') and run 'git pull' manually before running the workflow.") } + if !c.Verbose { + fmt.Fprintln(os.Stderr, "Finished updating local branch.") + } if err := RunSpecificWorkflowInteractively(ctx, parsed.WorkflowName, c.Verbose, c.EngineOverride, c.RepoOverride, "", false, false, false); err != nil { fmt.Fprintln(os.Stderr, console.FormatErrorMessage(fmt.Sprintf("Failed to run workflow: %v", err)))