diff --git a/pkg/cmd/workflow/run/run.go b/pkg/cmd/workflow/run/run.go index 3ba64ad4a..b7ab53098 100644 --- a/pkg/cmd/workflow/run/run.go +++ b/pkg/cmd/workflow/run/run.go @@ -262,15 +262,11 @@ func runRun(opts *RunOptions) error { ref := opts.Ref - defaultBranch, err := api.RepoDefaultBranch(client, repo) - if err != nil { - return fmt.Errorf("unable to determine default branch for %s: %w", ghrepo.FullName(repo), err) - } - - if ref != "" && ref != defaultBranch { - return fmt.Errorf("ref %s is not the default branch, and workflows must be on the default branch to be triggered by workflow_dispatch", ref) - } else { - ref = defaultBranch + if ref == "" { + ref, err = api.RepoDefaultBranch(client, repo) + if err != nil { + return fmt.Errorf("unable to determine default branch for %s: %w", ghrepo.FullName(repo), err) + } } states := []shared.WorkflowState{shared.Active}