Skip to main content

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/workflows

Parameters

NameTypeInDescription
acceptstringheader

Setting toapplication/vnd.github.v3+json is recommended.

ownerstringpath
repostringpath
per_pageintegerquery

Results per page (max 100)

Default: 30

pageintegerquery

Page number of the results to fetch.

Default: 1

Code samples

Example

Shell
curl \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/OWNER/REPO/actions/workflows
JavaScript @octokit/core.js
await octokit.request('GET /repos/{owner}/{repo}/actions/workflows', { owner: 'OWNER', repo: 'REPO' })
GitHub CLI gh api
gh api \ -H "Accept: application/vnd.github.v3+json" \ /repos/OWNER/REPO/actions/workflows

Response

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 CodeDescription
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

NameTypeInDescription
acceptstringheader

Setting toapplication/vnd.github.v3+json is recommended.

ownerstringpath
repostringpath
workflow_idpath

The ID of the workflow. You can also pass the workflow file name as a string.

Code samples

Example

Shell
curl \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID
JavaScript @octokit/core.js
await octokit.request('GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}', { owner: 'OWNER', repo: 'REPO', workflow_id: 'WORKFLOW_ID' })
GitHub CLI gh api
gh api \ -H "Accept: application/vnd.github.v3+json" \ /repos/OWNER/REPO/actions/workflows/WORKFLOW_ID

Response

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 CodeDescription
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}/disable

Parameters

NameTypeInDescription
acceptstringheader

Setting toapplication/vnd.github.v3+json is recommended.

ownerstringpath
repostringpath
workflow_idpath

The ID of the workflow. You can also pass the workflow file name as a string.

Code samples

Example

Shell
curl \ -X PUT \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/disable
JavaScript @octokit/core.js
await octokit.request('PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable', { owner: 'OWNER', repo: 'REPO', workflow_id: 'WORKFLOW_ID' })
GitHub CLI gh api
gh api \ --method PUT \ -H "Accept: application/vnd.github.v3+json" \ /repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/disable

Response

Status: 204

Status codes

HTTP Status CodeDescription
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}/dispatches

Parameters

NameTypeInDescription
acceptstringheader

Setting toapplication/vnd.github.v3+json is recommended.

ownerstringpath
repostringpath
workflow_idpath

The ID of the workflow. You can also pass the workflow file name as a string.

refstringbody

Required. The git reference for the workflow. The reference can be a branch or tag name.

inputsobjectbody

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 inputs are omitted.

Code samples

Example

Shell
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"}}'
JavaScript @octokit/core.js
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: 204

Status codes

HTTP Status CodeDescription
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}/enable

Parameters

NameTypeInDescription
acceptstringheader

Setting toapplication/vnd.github.v3+json is recommended.

ownerstringpath
repostringpath
workflow_idpath

The ID of the workflow. You can also pass the workflow file name as a string.

Code samples

Example

Shell
curl \ -X PUT \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/enable
JavaScript @octokit/core.js
await octokit.request('PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable', { owner: 'OWNER', repo: 'REPO', workflow_id: 'WORKFLOW_ID' })
GitHub CLI gh api
gh api \ --method PUT \ -H "Accept: application/vnd.github.v3+json" \ /repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/enable

Response

Status: 204

Status codes

HTTP Status CodeDescription
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}/timing

Parameters

NameTypeInDescription
acceptstringheader

Setting toapplication/vnd.github.v3+json is recommended.

ownerstringpath
repostringpath
workflow_idpath

The ID of the workflow. You can also pass the workflow file name as a string.

Code samples

Example

Shell
curl \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/timing
JavaScript @octokit/core.js
await octokit.request('GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/timing', { owner: 'OWNER', repo: 'REPO', workflow_id: 'WORKFLOW_ID' })
GitHub CLI gh api
gh api \ -H "Accept: application/vnd.github.v3+json" \ /repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/timing

Response

Status: 200
{ "billable": { "UBUNTU": { "total_ms": 180000 }, "MACOS": { "total_ms": 240000 }, "WINDOWS": { "total_ms": 300000 } } }

Status codes

HTTP Status CodeDescription
200

OK