Merge pull request #10328 from iamazeem/9781-gh-workflow-run-default-branch-validation

[gh workflow run] Improve error handling for `--ref` flag
This commit is contained in:
Tyler McGoffin 2025-02-06 10:03:47 -08:00 committed by GitHub
commit 756ba75c9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -131,7 +131,10 @@ func FindWorkflow(client *api.Client, repo ghrepo.Interface, workflowSelector st
if _, err := strconv.Atoi(workflowSelector); err == nil || isWorkflowFile(workflowSelector) {
workflow, err := getWorkflowByID(client, repo, workflowSelector)
if err != nil {
return nil, err
var httpErr api.HTTPError
if errors.As(err, &httpErr) && httpErr.StatusCode == 404 {
return nil, fmt.Errorf("workflow %s not found on the default branch", workflowSelector)
}
}
return []Workflow{*workflow}, nil
}