Workflows
The Workflows API allows you to view workflows for a repository.
Workflows automate your software development life cycle with a wide range of tools and services. For more information, see "Automating your workflow with GitHub Actions."
This API is available for authenticated users, OAuth Apps, and GitHub Apps. Access tokens require repo scope for private repositories and public_repo scope for public repositories. GitHub Apps must have the actions permission to use this API.
List repository workflows
Lists the workflows in a repository. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.
get /repos/{owner}/{repo}/actions/workflowsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
per_page | integer | query | Results per page (max 100) Default: |
page | integer | query | Page number of the results to fetch. Default: |
Code samples
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/actions/workflowsawait octokit.request('GET /repos/{owner}/{repo}/actions/workflows', {
owner: 'OWNER',
repo: 'REPO'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/actions/workflowsResponse
Status: 200{
"total_count": 2,
"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"
},
{
"id": 269289,
"node_id": "MDE4OldvcmtmbG93IFNlY29uZGFyeTI2OTI4OQ==",
"name": "Linter",
"path": ".github/workflows/linter.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/269289",
"html_url": "https://github.com/octo-org/octo-repo/blob/master/.github/workflows/269289",
"badge_url": "https://github.com/octo-org/octo-repo/workflows/Linter/badge.svg"
}
]
}Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |
Notes
Get a workflow
Gets a specific workflow. You can replace workflow_id with the workflow file name. For example, you could use main.yaml. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.
get /repos/{owner}/{repo}/actions/workflows/{workflow_id}Parameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
workflow_id | path | The ID of the workflow. You can also pass the workflow file name as a string. |
Code samples
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_IDawait octokit.request('GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}', {
owner: 'OWNER',
repo: 'REPO',
workflow_id: 'WORKFLOW_ID'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/actions/workflows/WORKFLOW_IDResponse
Status: 200{
"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"
}Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |
Notes
Disable a workflow
Disables a workflow and sets the state of the workflow to disabled_manually. You can replace workflow_id with the workflow file name. For example, you could use main.yaml.
You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the actions:write permission to use this endpoint.
put /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disableParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
workflow_id | path | The ID of the workflow. You can also pass the workflow file name as a string. |
Code samples
Example
curl \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/disableawait octokit.request('PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable', {
owner: 'OWNER',
repo: 'REPO',
workflow_id: 'WORKFLOW_ID'
})gh api \
--method PUT \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/disableResponse
Status: 204Status codes
| HTTP Status Code | Description |
|---|---|
204 | No Content |
Notes
Create a workflow dispatch event
You can use this endpoint to manually trigger a GitHub Actions workflow run. You can replace workflow_id with the workflow file name. For example, you could use main.yaml.
You must configure your GitHub Actions workflow to run when the workflow_dispatch webhook event occurs. The inputs are configured in the workflow file. For more information about how to configure the workflow_dispatch event in the workflow file, see "Events that trigger workflows."
You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the actions:write permission to use this endpoint. For more information, see "Creating a personal access token for the command line."
post /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatchesParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
workflow_id | path | The ID of the workflow. You can also pass the workflow file name as a string. | |
ref | string | body | Required. The git reference for the workflow. The reference can be a branch or tag name. |
inputs | object | body | Input keys and values configured in the workflow file. The maximum number of properties is 10. Any default properties configured in the workflow file will be used when |
Code samples
Example
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/dispatches \
-d '{"ref":"topic-branch","inputs":{"name":"Mona the Octocat","home":"San Francisco, CA"}}'await octokit.request('POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches', {
owner: 'OWNER',
repo: 'REPO',
workflow_id: 'WORKFLOW_ID',
ref: 'topic-branch',
inputs: {
name: 'Mona the Octocat',
home: 'San Francisco, CA'
}
})Response
Status: 204Status codes
| HTTP Status Code | Description |
|---|---|
204 | No Content |
Notes
Enable a workflow
Enables a workflow and sets the state of the workflow to active. You can replace workflow_id with the workflow file name. For example, you could use main.yaml.
You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the actions:write permission to use this endpoint.
put /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enableParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
workflow_id | path | The ID of the workflow. You can also pass the workflow file name as a string. |
Code samples
Example
curl \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/enableawait octokit.request('PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable', {
owner: 'OWNER',
repo: 'REPO',
workflow_id: 'WORKFLOW_ID'
})gh api \
--method PUT \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/enableResponse
Status: 204Status codes
| HTTP Status Code | Description |
|---|---|
204 | No Content |
Notes
Get workflow usage
Gets the number of billable minutes used by a specific workflow during the current billing cycle. Billable minutes only apply to workflows in private repositories that use GitHub-hosted runners. Usage is listed for each GitHub-hosted runner operating system in milliseconds. Any job re-runs are also included in the usage. The usage does not include the multiplier for macOS and Windows runners and is not rounded up to the nearest whole minute. For more information, see "Managing billing for GitHub Actions".
You can replace workflow_id with the workflow file name. For example, you could use main.yaml. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.
get /repos/{owner}/{repo}/actions/workflows/{workflow_id}/timingParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
workflow_id | path | The ID of the workflow. You can also pass the workflow file name as a string. |
Code samples
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/timingawait octokit.request('GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/timing', {
owner: 'OWNER',
repo: 'REPO',
workflow_id: 'WORKFLOW_ID'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/timingResponse
Status: 200{
"billable": {
"UBUNTU": {
"total_ms": 180000
},
"MACOS": {
"total_ms": 240000
},
"WINDOWS": {
"total_ms": 300000
}
}
}Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |