GitHub Actions Artifacts
Utilisez l’API REST pour interagir avec les artefacts dans GitHub Actions.
À propos des artefacts dans GitHub Actions
Vous pouvez utiliser l’API REST pour télécharger, supprimer et récupérer des informations sur les artefacts du workflow dans GitHub Actions. Artifacts vous permet de partager des données entre travaux dans un workflow, et de stocker des données une fois ce workflow terminé. Pour plus d’informations, consultez « Stockage des données de workflow en tant qu’artefacts ».
Ces points de terminaison sont disponibles pour les utilisateurs authentifiés, les OAuth Apps et les GitHub Apps. Les jetons d’accès nécessitent une étendue repo
pour les dépôts privés et une étendue public_repo
pour les dépôts publics. GitHub Apps doit avoir l’autorisation actions
pour utiliser ces points de terminaison.
List artifacts for a repository
Lists all artifacts for 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.
Paramètres pour « List artifacts for a repository »
En-têtes |
---|
Nom, Type, Description |
accept string Setting to |
Paramètres de chemin d’accès |
Nom, Type, Description |
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository. The name is not case sensitive. |
Paramètres de requête |
Nom, Type, Description |
per_page integer The number of results per page (max 100). Default: |
page integer Page number of the results to fetch. Default: |
Codes d’état de la réponse HTTP pour « List artifacts for a repository »
Code d’état | Description |
---|---|
200 | OK |
Exemples de code pour « List artifacts for a repository »
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/actions/artifacts
Response
Status: 200
{
"total_count": 2,
"artifacts": [
{
"id": 11,
"node_id": "MDg6QXJ0aWZhY3QxMQ==",
"name": "Rails",
"size_in_bytes": 556,
"url": "https://HOSTNAME/repos/octo-org/octo-docs/actions/artifacts/11",
"archive_download_url": "https://HOSTNAME/repos/octo-org/octo-docs/actions/artifacts/11/zip",
"expired": false,
"created_at": "2020-01-10T14:59:22Z",
"expires_at": "2020-03-21T14:59:22Z",
"updated_at": "2020-02-21T14:59:22Z",
"workflow_run": {
"id": 2332938,
"repository_id": 1296269,
"head_repository_id": 1296269,
"head_branch": "main",
"head_sha": "328faa0536e6fef19753d9d91dc96a9931694ce3"
}
},
{
"id": 13,
"node_id": "MDg6QXJ0aWZhY3QxMw==",
"name": "Test output",
"size_in_bytes": 453,
"url": "https://HOSTNAME/repos/octo-org/octo-docs/actions/artifacts/13",
"archive_download_url": "https://HOSTNAME/repos/octo-org/octo-docs/actions/artifacts/13/zip",
"expired": false,
"created_at": "2020-01-10T14:59:22Z",
"expires_at": "2020-03-21T14:59:22Z",
"updated_at": "2020-02-21T14:59:22Z",
"workflow_run": {
"id": 2332942,
"repository_id": 1296269,
"head_repository_id": 1296269,
"head_branch": "main",
"head_sha": "178f4f6090b3fccad4a65b3e83d076a622d59652"
}
}
]
}
Get an artifact
Gets a specific artifact for a workflow run. 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.
Paramètres pour « Get an artifact »
En-têtes |
---|
Nom, Type, Description |
accept string Setting to |
Paramètres de chemin d’accès |
Nom, Type, Description |
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository. The name is not case sensitive. |
artifact_id integer ObligatoireThe unique identifier of the artifact. |
Codes d’état de la réponse HTTP pour « Get an artifact »
Code d’état | Description |
---|---|
200 | OK |
Exemples de code pour « Get an artifact »
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/actions/artifacts/ARTIFACT_ID
Response
Status: 200
{
"id": 11,
"node_id": "MDg6QXJ0aWZhY3QxMQ==",
"name": "Rails",
"size_in_bytes": 556,
"url": "https://HOSTNAME/repos/octo-org/octo-docs/actions/artifacts/11",
"archive_download_url": "https://HOSTNAME/repos/octo-org/octo-docs/actions/artifacts/11/zip",
"expired": false,
"created_at": "2020-01-10T14:59:22Z",
"expires_at": "2020-01-21T14:59:22Z",
"updated_at": "2020-01-21T14:59:22Z",
"workflow_run": {
"id": 2332938,
"repository_id": 1296269,
"head_repository_id": 1296269,
"head_branch": "main",
"head_sha": "328faa0536e6fef19753d9d91dc96a9931694ce3"
}
}
Delete an artifact
Deletes an artifact for a workflow run. 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.
Paramètres pour « Delete an artifact »
En-têtes |
---|
Nom, Type, Description |
accept string Setting to |
Paramètres de chemin d’accès |
Nom, Type, Description |
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository. The name is not case sensitive. |
artifact_id integer ObligatoireThe unique identifier of the artifact. |
Codes d’état de la réponse HTTP pour « Delete an artifact »
Code d’état | Description |
---|---|
204 | No Content |
Exemples de code pour « Delete an artifact »
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/actions/artifacts/ARTIFACT_ID
Response
Status: 204
Download an artifact
Gets a redirect URL to download an archive for a repository. This URL expires after 1 minute. Look for Location:
in
the response header to find the URL for the download. The :archive_format
must be zip
. 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.
Paramètres pour « Download an artifact »
En-têtes |
---|
Nom, Type, Description |
accept string Setting to |
Paramètres de chemin d’accès |
Nom, Type, Description |
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository. The name is not case sensitive. |
artifact_id integer ObligatoireThe unique identifier of the artifact. |
archive_format string Obligatoire |
Codes d’état de la réponse HTTP pour « Download an artifact »
Code d’état | Description |
---|---|
302 | Found |
410 | Gone |
Exemples de code pour « Download an artifact »
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/actions/artifacts/ARTIFACT_ID/ARCHIVE_FORMAT
Response
Status: 302
List workflow run artifacts
Lists artifacts for a workflow run. 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.
Paramètres pour « List workflow run artifacts »
En-têtes |
---|
Nom, Type, Description |
accept string Setting to |
Paramètres de chemin d’accès |
Nom, Type, Description |
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository. The name is not case sensitive. |
run_id integer ObligatoireThe unique identifier of the workflow run. |
Paramètres de requête |
Nom, Type, Description |
per_page integer The number of results per page (max 100). Default: |
page integer Page number of the results to fetch. Default: |
Codes d’état de la réponse HTTP pour « List workflow run artifacts »
Code d’état | Description |
---|---|
200 | OK |
Exemples de code pour « List workflow run artifacts »
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/actions/runs/RUN_ID/artifacts
Response
Status: 200
{
"total_count": 2,
"artifacts": [
{
"id": 11,
"node_id": "MDg6QXJ0aWZhY3QxMQ==",
"name": "Rails",
"size_in_bytes": 556,
"url": "https://HOSTNAME/repos/octo-org/octo-docs/actions/artifacts/11",
"archive_download_url": "https://HOSTNAME/repos/octo-org/octo-docs/actions/artifacts/11/zip",
"expired": false,
"created_at": "2020-01-10T14:59:22Z",
"expires_at": "2020-03-21T14:59:22Z",
"updated_at": "2020-02-21T14:59:22Z",
"workflow_run": {
"id": 2332938,
"repository_id": 1296269,
"head_repository_id": 1296269,
"head_branch": "main",
"head_sha": "328faa0536e6fef19753d9d91dc96a9931694ce3"
}
},
{
"id": 13,
"node_id": "MDg6QXJ0aWZhY3QxMw==",
"name": "Test output",
"size_in_bytes": 453,
"url": "https://HOSTNAME/repos/octo-org/octo-docs/actions/artifacts/13",
"archive_download_url": "https://HOSTNAME/repos/octo-org/octo-docs/actions/artifacts/13/zip",
"expired": false,
"created_at": "2020-01-10T14:59:22Z",
"expires_at": "2020-03-21T14:59:22Z",
"updated_at": "2020-02-21T14:59:22Z",
"workflow_run": {
"id": 2332942,
"repository_id": 1296269,
"head_repository_id": 1296269,
"head_branch": "main",
"head_sha": "178f4f6090b3fccad4a65b3e83d076a622d59652"
}
}
]
}