I am following this documentation: https://docs.github.com/en/rest/reference/actions#list-repository-workflows
/repos/{owner}/{repo}/actions/workflows
My sample output looks like this:
{
"total_count": 1,
"workflows": [
{
"id": 161335,
"node_id": "MDg6V29ya2Zsb3cxNjEzMzU=",
"name": "CI",
"path": ".github/workflows/blank.yaml",
"state": "active",
"created_at": "2020-01-08T23:48:37.000-08:00",
"updated_at": "2020-01-08T23:50:21.000-08:00",
"url": "https://api.github.com/repos/octo-org/octo-repo/actions/workflows/161335",
"html_url": "https://github.com/octo-org/octo-repo/blob/master/.github/workflows/161335",
"badge_url": "https://github.com/octo-org/octo-repo/workflows/CI/badge.svg"
}
]
}
How do I fetch the workflow yaml file from this output
CodePudding user response:
Given the filename, use the Get repository content API to fetch the file.
For your file, that'd be:
curl \
-H "Accept: application/vnd.github.v3 json" \
https://api.github.com/repos/octo-org/octo-repo/contents/.github/workflows/blank.yaml
The response JSON will contain a field content
, which contains the encoded contents of that workflow.