Points de terminaison d’API REST pour les workflows
Utilisez l’API REST pour interagir avec les workflows pour GitHub Actions.
À propos des workflows dans GitHub Actions
Vous pouvez utiliser l’API REST pour afficher les workflows d’un référentiel dans GitHub Actions. Les workflows permettent d’automatiser le cycle de vie de votre développement logiciel grâce à un large éventail d’outils et de services. Pour plus d’informations, consultez « À propos des workflows » dans la documentation GitHub Actions.
List repository workflows
Lists the workflows in a repository.
Anyone with read access to the repository can use this endpoint.
OAuth app tokens and personal access tokens (classic) need the repo
scope to use this endpoint with a private repository.
Jetons d’accès affinés pour « List repository workflows »
Ce point de terminaison fonctionne avec les types de jetons précis suivants:
- Jetons d’accès utilisateur d’application GitHub
- Jetons d’accès d’installation d’application GitHub
- Jetons d’accès personnel affiné
Le jeton précis doit avoir l’ensemble d’autorisations suivant:
- "Actions" repository permissions (read)
Ce point de terminaison peut être utilisé sans authentification ou sans les autorisations mentionnées ci-dessus si seules les ressources publiques sont demandées.
Paramètres pour « List repository workflows »
Nom, Type, Description |
---|
accept string Setting to |
Nom, Type, Description |
---|
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository without the |
Nom, Type, Description |
---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Default: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Default: |
Codes d’état de la réponse HTTP pour « List repository workflows »
Code d’état | Description |
---|---|
200 | OK |
Exemples de code pour « List repository workflows »
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
Exemple de requête
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/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
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.
OAuth app tokens and personal access tokens (classic) need the repo
scope to use this endpoint with a private repository.
Jetons d’accès affinés pour « Get a workflow »
Ce point de terminaison fonctionne avec les types de jetons précis suivants:
- Jetons d’accès utilisateur d’application GitHub
- Jetons d’accès d’installation d’application GitHub
- Jetons d’accès personnel affiné
Le jeton précis doit avoir l’ensemble d’autorisations suivant:
- "Actions" repository permissions (read)
Ce point de terminaison peut être utilisé sans authentification ou sans les autorisations mentionnées ci-dessus si seules les ressources publiques sont demandées.
Paramètres pour « Get a workflow »
Nom, Type, Description |
---|
accept string Setting to |
Nom, Type, Description |
---|
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository without the |
workflow_id ObligatoireThe ID of the workflow. You can also pass the workflow file name as a string. |
Codes d’état de la réponse HTTP pour « Get a workflow »
Code d’état | Description |
---|---|
200 | OK |
Exemples de code pour « Get a workflow »
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
Exemple de requête
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/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
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
.
OAuth tokens and personal access tokens (classic) need the repo
scope to use this endpoint.
Jetons d’accès affinés pour « Disable a workflow »
Ce point de terminaison fonctionne avec les types de jetons précis suivants:
- Jetons d’accès utilisateur d’application GitHub
- Jetons d’accès d’installation d’application GitHub
- Jetons d’accès personnel affiné
Le jeton précis doit avoir l’ensemble d’autorisations suivant:
- "Actions" repository permissions (write)
Paramètres pour « Disable a workflow »
Nom, Type, Description |
---|
accept string Setting to |
Nom, Type, Description |
---|
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository without the |
workflow_id ObligatoireThe ID of the workflow. You can also pass the workflow file name as a string. |
Codes d’état de la réponse HTTP pour « Disable a workflow »
Code d’état | Description |
---|---|
204 | No Content |
Exemples de code pour « Disable a workflow »
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
Exemple de requête
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/disable
Response
Status: 204
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."
OAuth tokens and personal access tokens (classic) need the repo
scope to use this endpoint.
Jetons d’accès affinés pour « Create a workflow dispatch event »
Ce point de terminaison fonctionne avec les types de jetons précis suivants:
- Jetons d’accès utilisateur d’application GitHub
- Jetons d’accès d’installation d’application GitHub
- Jetons d’accès personnel affiné
Le jeton précis doit avoir l’ensemble d’autorisations suivant:
- "Actions" repository permissions (write)
Paramètres pour « Create a workflow dispatch event »
Nom, Type, Description |
---|
accept string Setting to |
Nom, Type, Description |
---|
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository without the |
workflow_id ObligatoireThe ID of the workflow. You can also pass the workflow file name as a string. |
Nom, Type, Description |
---|
ref string ObligatoireThe git reference for the workflow. The reference can be a branch or tag name. |
inputs object 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 |
Codes d’état de la réponse HTTP pour « Create a workflow dispatch event »
Code d’état | Description |
---|---|
204 | No Content |
Exemples de code pour « Create a workflow dispatch event »
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
Exemple de requête
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
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"}}'
Response
Status: 204
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
.
OAuth tokens and personal access tokens (classic) need the repo
scope to use this endpoint.
Jetons d’accès affinés pour « Enable a workflow »
Ce point de terminaison fonctionne avec les types de jetons précis suivants:
- Jetons d’accès utilisateur d’application GitHub
- Jetons d’accès d’installation d’application GitHub
- Jetons d’accès personnel affiné
Le jeton précis doit avoir l’ensemble d’autorisations suivant:
- "Actions" repository permissions (write)
Paramètres pour « Enable a workflow »
Nom, Type, Description |
---|
accept string Setting to |
Nom, Type, Description |
---|
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository without the |
workflow_id ObligatoireThe ID of the workflow. You can also pass the workflow file name as a string. |
Codes d’état de la réponse HTTP pour « Enable a workflow »
Code d’état | Description |
---|---|
204 | No Content |
Exemples de code pour « Enable a workflow »
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
Exemple de requête
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/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 Enterprise Cloud-hosted runners. Usage is listed for each GitHub Enterprise Cloud-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.
OAuth app tokens and personal access tokens (classic) need the repo
scope to use this endpoint with a private repository.
Jetons d’accès affinés pour « Get workflow usage »
Ce point de terminaison fonctionne avec les types de jetons précis suivants:
- Jetons d’accès utilisateur d’application GitHub
- Jetons d’accès d’installation d’application GitHub
- Jetons d’accès personnel affiné
Le jeton précis doit avoir l’ensemble d’autorisations suivant:
- "Actions" repository permissions (read)
Ce point de terminaison peut être utilisé sans authentification ou sans les autorisations mentionnées ci-dessus si seules les ressources publiques sont demandées.
Paramètres pour « Get workflow usage »
Nom, Type, Description |
---|
accept string Setting to |
Nom, Type, Description |
---|
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository without the |
workflow_id ObligatoireThe ID of the workflow. You can also pass the workflow file name as a string. |
Codes d’état de la réponse HTTP pour « Get workflow usage »
Code d’état | Description |
---|---|
200 | OK |
Exemples de code pour « Get workflow usage »
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
Exemple de requête
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/timing
Response
Status: 200
{
"billable": {
"UBUNTU": {
"total_ms": 180000
},
"MACOS": {
"total_ms": 240000
},
"WINDOWS": {
"total_ms": 300000
}
}
}