已关闭
feat(actions): 支持 列出仓库的 Artifacts API #439
aflyingto创建于 7月9日关闭于 7月10日
aflyingto
7月10日 评论:
7月10日 评论:
验证记录
- 当前版本: main @ 28c60a1(含 M1 全部 5 命令)
- 需求确认: GitCode API v8 提供
GET /api/v8/repos/{owner}/{repo}/actions/artifacts(列出仓库 Artifacts),OpenAPI 已抓取于本 issue body。响应{total_count, artifacts:[...]},每项含 id/name/size_bytes/workflow_id/workflow_run_id/digest/expires_at/created_at/updated_at(时间为字符串型毫秒时间戳)。支持 name 过滤 + sort(created)/direction + page/per_page 分页。 - gc 现状: 无 artifacts 命令(M2 未启动);api 无 artifact 查询。
- 重复检查: 无 merged PR,origin/main 无对应代码,verify-remote-facts passed
- 结论: 需求有效且未实现,进入开发
实现计划
- API 层:
api/queries_actions.go加Artifact/ArtifactsResponse/ActionsListArtifactsOptions类型 +ListActionsArtifacts(RawREST 走 v8 artifacts,query name/sort/direction/page/per_page 经 url.Values)。 - 命令层: 新建
pkg/cmd/actions/artifact/artifact.go(artifact 父组,为 #441 view/#440 download/#433 delete 预留)+artifact/list/list.go(gc actions artifact list -R owner/repo [--name] [--sort] [--direction] [--page] [--per-page] [--json] [--format],镜像 #445 run list)。注册到 actions 父命令。 - 输出:
pkg/output/artifacts.go(WorkflowArtifactListPrinter,table/simple + size 人类可读 + created/expires ms 时间格式化)。 - 真实验证: infra-test(无 artifacts,验空结果/404)+ wangjing_127/MindIE-SD 实数确认(有流水线,可能有 artifacts)。


背景
GitCode API 文档 2.0.0 已提供 Actions API。该 Issue 用于跟踪 gitcode-cli 对此接口的支持设计与实现。
API 摘要
GET/api/v8/repos/{owner}/{repo}/actions/artifactsget_api_v8_repos_{owner}_{repo}_actions_artifactspipeline-v8falseRequest Parameters
ownerrepoaccess_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": "分页查询仓库下的制品,支持按名称过滤及排序。", "operationId": "get_api_v8_repos_{owner}_{repo}_actions_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": "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": "当前页码", "required": false, "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/artifacts", "servers": [ { "url": "https://api.gitcode.com", "description": "正式环境" } ], "securitySchemes": {}, "info": { "title": "GicodeOpenAPI", "description": "", "version": "1.0.0" }, "postman": { "name": "列出仓库的 Artifacts", "description": { "content": "分页查询仓库下的制品,支持按名称过滤及排序。", "type": "text/plain" }, "url": { "path": [ "api", "v8", "repos", ":owner", ":repo", "actions", "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" } ] }, "header": [ { "key": "Accept", "value": "application/json" } ], "method": "GET" } }初步验收建议
infra-test/*仓库。access_token仅作为 API 参数记录,CLI 优先复用现有认证机制。