Closed
feat(actions): 支持 列出特定 Run 的 Artifacts API #447
aflyingtoAdd on Jul 9Closed at Jul 10
aflyingto
Jul 10 Comments:
Jul 10 Comments:
验证记录
- 当前版本: main @ 697eba0(含 #439 artifact list)
- 需求确认: GitCode API v8 提供
GET /api/v8/repos/{owner}/{repo}/actions/runs/{run_id}/artifacts(列出特定 Run 的 Artifacts),OpenAPI 已抓取于本 issue body。响应同 #439({total_count, artifacts:[Artifact]}),故复用 Artifact 类型 + printer。支持 name/sort/direction/page/per_page。 - gc 现状: 有
gc actions artifact list(#439,repo-level);无 run-scoped artifact 列表。 - 重复检查: 无 merged PR,origin/main 无对应代码,verify-remote-facts passed
- 结论: 需求有效且未实现,进入开发
实现计划
- API 层:
ListActionsRunArtifacts(client, owner, repo, runID, opts)(RawREST 走 v8 runs/{run_id}/artifacts,复用 ActionsListArtifactsOptions + ArtifactsResponse + Artifact 类型)。 - 命令层: 给 #439 的
artifact list加--run <run-id>flag;listArtifacts 分支:RunID 非空→ListActionsRunArtifacts,否则→ListActionsArtifacts。printer/分页/--json 全复用。 - 真实验证: infra-test 404 + wangjing_127 run #55(其 runs 无 artifacts,验空 + run-scoped 路由)。


背景
GitCode API 文档 2.0.0 已提供 Actions API。该 Issue 用于跟踪 gitcode-cli 对此接口的支持设计与实现。
API 摘要
GET/api/v8/repos/{owner}/{repo}/actions/runs/{run_id}/artifactsget_api_v8_repos_{owner}_{repo}_actions_runs_{run_id}_artifactspipeline-v8falseRequest Parameters
ownerreporun_idaccess_tokennamesortdirectionpageper_pageRequest Body
无。
Responses
200
application/jsonapplication/json schema
{ "type": "object", "properties": { "total_count": { "type": "integer", "description": "制品总数" }, "artifacts": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "制品ID" }, "name": { "type": "string", "description": "制品名称" }, "size_bytes": { "type": "integer", "description": "制品大小(字节)" }, "workflow_id": { "type": "string", "description": "工作流ID" }, "workflow_run_id": { "type": "string", "description": "工作流运行ID" }, "digest": { "type": "string", "description": "SHA256 摘要" }, "expires_at": { "type": "string", "description": "过期时间(毫秒时间戳)" }, "created_at": { "type": "string", "description": "创建时间(毫秒时间戳)" }, "updated_at": { "type": "string", "description": "更新时间(毫秒时间戳)" } }, "description": "制品列表" }, "description": "制品列表" } }, "description": "com.gitcode.openapi.pojo.artifact.BizArtifactListResp" }原始 OpenAPI Operation
{ "deprecated": false, "description": "分页查询指定 Workflow Run 产生的所有制品,支持按创建时间排序。", "operationId": "get_api_v8_repos_{owner}_{repo}_actions_runs_{run_id}_artifacts", "tags": [ "pipeline-v8" ], "parameters": [ { "name": "owner", "in": "path", "description": "仓库所属空间地址(组织或个人的地址path)", "required": true, "schema": { "type": "string" } }, { "name": "repo", "in": "path", "description": "仓库路径(path)", "required": true, "schema": { "type": "string" } }, { "name": "run_id", "in": "path", "description": "流水线运行id", "required": true, "schema": { "type": "string" } }, { "name": "access_token", "in": "query", "description": "用户授权码", "required": false, "schema": { "type": "string" } }, { "name": "name", "in": "query", "description": "制品名称过滤(模糊匹配)", "example": "", "schema": { "type": "string" } }, { "name": "sort", "in": "query", "description": "排序字段,当前仅支持created", "example": "", "schema": { "type": "string" } }, { "name": "direction", "in": "query", "description": "排序方向,asc 或 desc", "example": "", "schema": { "type": "string" } }, { "name": "page", "in": "query", "description": "当前页码", "example": 1, "schema": { "type": "integer" } }, { "name": "per_page", "in": "query", "description": "每页的项目数", "example": 10, "schema": { "type": "integer" } } ], "responses": { "200": { "description": "", "content": { "application/json": { "schema": { "type": "object", "properties": { "total_count": { "type": "integer", "description": "制品总数" }, "artifacts": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "制品ID" }, "name": { "type": "string", "description": "制品名称" }, "size_bytes": { "type": "integer", "description": "制品大小(字节)" }, "workflow_id": { "type": "string", "description": "工作流ID" }, "workflow_run_id": { "type": "string", "description": "工作流运行ID" }, "digest": { "type": "string", "description": "SHA256 摘要" }, "expires_at": { "type": "string", "description": "过期时间(毫秒时间戳)" }, "created_at": { "type": "string", "description": "创建时间(毫秒时间戳)" }, "updated_at": { "type": "string", "description": "更新时间(毫秒时间戳)" } }, "description": "制品列表" }, "description": "制品列表" } }, "description": "com.gitcode.openapi.pojo.artifact.BizArtifactListResp" } } }, "headers": {} } }, "security": [], "method": "get", "path": "/api/v8/repos/{owner}/{repo}/actions/runs/{run_id}/artifacts", "servers": [ { "url": "https://api.gitcode.com", "description": "正式环境" } ], "securitySchemes": {}, "info": { "title": "GicodeOpenAPI", "description": "", "version": "1.0.0" }, "postman": { "name": "列出特定 Run 的 Artifacts", "description": { "content": "分页查询指定 Workflow Run 产生的所有制品,支持按创建时间排序。", "type": "text/plain" }, "url": { "path": [ "api", "v8", "repos", ":owner", ":repo", "actions", "runs", ":run_id", "artifacts" ], "host": [ "{{baseUrl}}" ], "query": [ { "disabled": false, "description": { "content": "用户授权码", "type": "text/plain" }, "key": "access_token", "value": "" }, { "disabled": false, "description": { "content": "制品名称过滤(模糊匹配)", "type": "text/plain" }, "key": "name", "value": "" }, { "disabled": false, "description": { "content": "排序字段,当前仅支持created", "type": "text/plain" }, "key": "sort", "value": "" }, { "disabled": false, "description": { "content": "排序方向,asc 或 desc", "type": "text/plain" }, "key": "direction", "value": "" }, { "disabled": false, "description": { "content": "当前页码", "type": "text/plain" }, "key": "page", "value": "" }, { "disabled": false, "description": { "content": "每页的项目数", "type": "text/plain" }, "key": "per_page", "value": "" } ], "variable": [ { "disabled": false, "description": { "content": "(Required) 仓库所属空间地址(组织或个人的地址path)", "type": "text/plain" }, "type": "any", "value": "", "key": "owner" }, { "disabled": false, "description": { "content": "(Required) 仓库路径(path)", "type": "text/plain" }, "type": "any", "value": "", "key": "repo" }, { "disabled": false, "description": { "content": "(Required) 流水线运行id", "type": "text/plain" }, "type": "any", "value": "", "key": "run_id" } ] }, "header": [ { "key": "Accept", "value": "application/json" } ], "method": "GET" } }初步验收建议
infra-test/*仓库。access_token仅作为 API 参数记录,CLI 优先复用现有认证机制。