Skip to main content
Publicamos atualizações frequentes em nossa documentação, e a tradução desta página ainda pode estar em andamento. Para obter as informações mais recentes, acesse a documentação em inglês. Se houver problemas com a tradução desta página, entre em contato conosco.
O GitHub AE está atualmente sob versão limitada. Entre em contato com nossa Equipe de Vendas para saber mais.

Fluxos de trabalho

A API de fluxos de trabalho permite que você veja fluxos de trabalho para um repositório.

Sobre a API de fluxos de trabalho

A API de fluxos de trabalho permite que você veja fluxos de trabalho para um repositório. Com os fluxos de trabalho, você pode automatizar o ciclo de vida de desenvolvimento de software usando várias ferramentas e serviços. Para obter mais informações, consulte "Automatizando seu fluxo de trabalho com o GitHub Actions".

Esta API está disponível para usuários autenticados, Aplicativos OAuth e Aplicativos do GitHub. Os tokens de acesso exigem o escopo repositório para repositórios privados e escopo public_repo para repositórios internos. Aplicativos do GitHub deve ter a permissão de ações para usar essa API.

List repository workflows

Works with GitHub Apps

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.

Parâmetros

Headers
Nome, Tipo, Descrição
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nome, Tipo, Descrição
ownerstringObrigatório

The account owner of the repository. The name is not case sensitive.

repostringObrigatório

The name of the repository. The name is not case sensitive.

Parâmetros de consulta
Nome, Tipo, Descrição
per_pageinteger

The number of results per page (max 100).

Padrão: 30

pageinteger

Page number of the results to fetch.

Padrão: 1

HTTP response status codes

Status codeDescrição
200

OK

Amostras de código

get/repos/{owner}/{repo}/actions/workflows
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: token <TOKEN>" \ https://HOSTNAME/api/v3/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" } ] }

Get a workflow

Works with GitHub Apps

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.

Parâmetros

Headers
Nome, Tipo, Descrição
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nome, Tipo, Descrição
ownerstringObrigatório

The account owner of the repository. The name is not case sensitive.

repostringObrigatório

The name of the repository. The name is not case sensitive.

workflow_idObrigatório

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

HTTP response status codes

Status codeDescrição
200

OK

Amostras de código

get/repos/{owner}/{repo}/actions/workflows/{workflow_id}
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: token <TOKEN>" \ https://HOSTNAME/api/v3/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" }

Disable a workflow

Works with GitHub Apps

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.

Parâmetros

Headers
Nome, Tipo, Descrição
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nome, Tipo, Descrição
ownerstringObrigatório

The account owner of the repository. The name is not case sensitive.

repostringObrigatório

The name of the repository. The name is not case sensitive.

workflow_idObrigatório

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

HTTP response status codes

Status codeDescrição
204

No Content

Amostras de código

put/repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable
curl \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: token <TOKEN>" \ https://HOSTNAME/api/v3/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/disable

Response

Status: 204

Create a workflow dispatch event

Works with GitHub Apps

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."

Parâmetros

Headers
Nome, Tipo, Descrição
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nome, Tipo, Descrição
ownerstringObrigatório

The account owner of the repository. The name is not case sensitive.

repostringObrigatório

The name of the repository. The name is not case sensitive.

workflow_idObrigatório

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

Body parameters
Nome, Tipo, Descrição
refstringObrigatório

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

inputsobject

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.

HTTP response status codes

Status codeDescrição
204

No Content

Amostras de código

post/repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches
curl \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: token <TOKEN>" \ https://HOSTNAME/api/v3/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/dispatches \ -d '{"ref":"topic-branch","inputs":{"name":"Mona the Octocat","home":"San Francisco, CA"}}'

Response

Status: 204

Enable a workflow

Works with GitHub Apps

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.

Parâmetros

Headers
Nome, Tipo, Descrição
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nome, Tipo, Descrição
ownerstringObrigatório

The account owner of the repository. The name is not case sensitive.

repostringObrigatório

The name of the repository. The name is not case sensitive.

workflow_idObrigatório

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

HTTP response status codes

Status codeDescrição
204

No Content

Amostras de código

put/repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable
curl \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: token <TOKEN>" \ https://HOSTNAME/api/v3/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/enable

Response

Status: 204

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 AE-hosted runners. Usage is listed for each GitHub AE-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.

Parâmetros

Headers
Nome, Tipo, Descrição
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nome, Tipo, Descrição
ownerstringObrigatório

The account owner of the repository. The name is not case sensitive.

repostringObrigatório

The name of the repository. The name is not case sensitive.

workflow_idObrigatório

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

HTTP response status codes

Status codeDescrição
200

OK

Amostras de código

get/repos/{owner}/{repo}/actions/workflows/{workflow_id}/timing
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: token <TOKEN>" \ https://HOSTNAME/api/v3/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/timing

Response

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