GitHub Actions 构件
GitHub Actions 构件 API 允许您下载、删除和检索有关工作流程构件的信息。
关于构件 API
GitHub Actions 构件 API 允许您下载、删除和检索有关工作流程构件的信息。 构件允许您在工作流程完成后,分享工作流程中作业之间的数据并存储数据。更多信息请参阅“使用构件持久化工作流程”。
此 API 适用于经过身份验证的用户、OAuth 应用程序 和 GitHub 应用程序。 访问令牌需要 repo 作用域(对于私有仓库)和 public_repo 作用域(对于公共仓库)。 GitHub 应用程序 必须具有 actions 权限才可使用此 API。
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. 默认值: |
HTTP 响应状态代码
| 状态代码 | 描述 |
|---|---|
200 | OK |
代码示例
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/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": "",
"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.v3+json" \
https://api.github.com/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.v3+json" \
https://api.github.com/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 |
代码示例
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/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.v3+json" \
https://api.github.com/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": "",
"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"
}
]
}