Артефакты GitHub Actions
Используйте REST API для взаимодействия с артефактами в GitHub Actions.
Сведения об артефактах в GitHub Actions
С помощью REST API можно скачивать, удалять и извлекать сведения об артефактах рабочих процессов в GitHub Actions. Артефакты позволяют обмениваться данными между заданиями в рабочем процессе и хранить данные после завершения рабочего процесса. Дополнительные сведения см. в разделе Хранение данных рабочего процесса как артефактов.
Эти конечные точки доступны для пользователей, прошедших проверку подлинности, OAuth Apps и GitHub Apps. Маркерам доступа требуется repo область для закрытых репозиториев и public_repo область для репозиториев public. GitHub Apps должно иметь разрешение на actions использование этих конечных точек.
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.
Параметры
| Заголовки |
|---|
| Имя, Тип, Описание |
acceptstringSetting to |
| Параметры пути |
| Имя, Тип, Описание |
ownerstringОбязательноThe account owner of the repository. The name is not case sensitive. |
repostringОбязательноThe name of the repository. The name is not case sensitive. |
| Параметры запроса |
| Имя, Тип, Описание |
per_pageintegerThe number of results per page (max 100). Значение по умолчанию: |
pageintegerPage number of the results to fetch. Значение по умолчанию: |
namestringFilters artifacts by exact match on their name field. |
Коды состояния HTTP-ответа
| Код состояния | Описание |
|---|---|
200 | OK |
Примеры кода
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/actions/artifactsResponse
Status: 200{
"total_count": 2,
"artifacts": [
{
"id": 11,
"node_id": "MDg6QXJ0aWZhY3QxMQ==",
"name": "Rails",
"size_in_bytes": 556,
"url": "https://api.github.com/repos/octo-org/octo-docs/actions/artifacts/11",
"archive_download_url": "https://api.github.com/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"
},
{
"id": 13,
"node_id": "MDg6QXJ0aWZhY3QxMw==",
"name": "Test output",
"size_in_bytes": 453,
"url": "https://api.github.com/repos/octo-org/octo-docs/actions/artifacts/13",
"archive_download_url": "https://api.github.com/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"
}
]
}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.
Параметры
| Заголовки |
|---|
| Имя, Тип, Описание |
acceptstringSetting to |
| Параметры пути |
| Имя, Тип, Описание |
ownerstringОбязательноThe account owner of the repository. The name is not case sensitive. |
repostringОбязательноThe name of the repository. The name is not case sensitive. |
artifact_idintegerОбязательноThe unique identifier of the artifact. |
Коды состояния HTTP-ответа
| Код состояния | Описание |
|---|---|
200 | OK |
Примеры кода
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/actions/artifacts/ARTIFACT_IDResponse
Status: 200{
"id": 11,
"node_id": "MDg6QXJ0aWZhY3QxMQ==",
"name": "Rails",
"size_in_bytes": 556,
"url": "https://api.github.com/repos/octo-org/octo-docs/actions/artifacts/11",
"archive_download_url": "https://api.github.com/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"
}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.
Параметры
| Заголовки |
|---|
| Имя, Тип, Описание |
acceptstringSetting to |
| Параметры пути |
| Имя, Тип, Описание |
ownerstringОбязательноThe account owner of the repository. The name is not case sensitive. |
repostringОбязательноThe name of the repository. The name is not case sensitive. |
artifact_idintegerОбязательноThe unique identifier of the artifact. |
Коды состояния HTTP-ответа
| Код состояния | Описание |
|---|---|
204 | No Content |
Примеры кода
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/actions/artifacts/ARTIFACT_IDResponse
Status: 204Download 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.
Параметры
| Заголовки |
|---|
| Имя, Тип, Описание |
acceptstringSetting to |
| Параметры пути |
| Имя, Тип, Описание |
ownerstringОбязательноThe account owner of the repository. The name is not case sensitive. |
repostringОбязательноThe name of the repository. The name is not case sensitive. |
artifact_idintegerОбязательноThe unique identifier of the artifact. |
archive_formatstringОбязательно |
Коды состояния HTTP-ответа
| Код состояния | Описание |
|---|---|
302 | Found |
410 | Gone |
Примеры кода
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/actions/artifacts/ARTIFACT_ID/ARCHIVE_FORMATResponse
Status: 302List 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.
Параметры
| Заголовки |
|---|
| Имя, Тип, Описание |
acceptstringSetting to |
| Параметры пути |
| Имя, Тип, Описание |
ownerstringОбязательноThe account owner of the repository. The name is not case sensitive. |
repostringОбязательноThe name of the repository. The name is not case sensitive. |
run_idintegerОбязательноThe unique identifier of the workflow run. |
| Параметры запроса |
| Имя, Тип, Описание |
per_pageintegerThe number of results per page (max 100). Значение по умолчанию: |
pageintegerPage number of the results to fetch. Значение по умолчанию: |
Коды состояния HTTP-ответа
| Код состояния | Описание |
|---|---|
200 | OK |
Примеры кода
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/actions/runs/RUN_ID/artifactsResponse
Status: 200{
"total_count": 2,
"artifacts": [
{
"id": 11,
"node_id": "MDg6QXJ0aWZhY3QxMQ==",
"name": "Rails",
"size_in_bytes": 556,
"url": "https://api.github.com/repos/octo-org/octo-docs/actions/artifacts/11",
"archive_download_url": "https://api.github.com/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"
},
{
"id": 13,
"node_id": "MDg6QXJ0aWZhY3QxMw==",
"name": "Test output",
"size_in_bytes": 453,
"url": "https://api.github.com/repos/octo-org/octo-docs/actions/artifacts/13",
"archive_download_url": "https://api.github.com/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"
}
]
}
