when I run this, I get results gh api repos/myorg/myrepo/actions/workflows/my-workflow.yaml/runs
. I wish to just grab runs from master branch, instead of doing that filtering afterwards. According to the docs "This endpoint will return up to 1,000 results for each search when using the following parameters: actor, branch, check_suite_id, created, event, head_sha, status."
However, if I add -f 'branch=master'
, -F 'branch=master'
, -f branch=master
, or -F branch=master
, I just get a 404:
gh: Not Found (HTTP 404)
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest",
"status": "404"
}
The branch name is correct. What is wrong with the parameters? Including headers does not work either and gives 404:
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
repos/myorg/myrepo/actions/workflows/my-workflow.yaml/runs -f "branch=master"
(I replaced org, repo, and workflow name with generics here.)
This endpoint wants HTTP GET requests, but if you add parameters to a GitHub CLI API request, it automatically switches to POST, see the manual:
The default HTTP request method is
GET
normally andPOST
if any parameters were added. Override the method with--method
.
So:
gh api repos/myorg/myrepo/actions/workflows/my-workflow.yaml/runs \
-f 'branch=master' \
-X GET
where -X
is short for --method
.