Closed
feat(actions): 支持 列出特定 Run 的 Artifacts API #447
aflyingtoAdd on  Jul 9Closed at  Jul 10
aflyingtoCollaborators
Jul 9 Create

背景

GitCode API 文档 2.0.0 已提供 Actions API。该 Issue 用于跟踪 gitcode-cli 对此接口的支持设计与实现。

API 摘要

  • 标题: 列出特定 Run 的 Artifacts
  • Method: GET
  • Path: /api/v8/repos/{owner}/{repo}/actions/runs/{run_id}/artifacts
  • Operation ID: get_api_v8_repos_{owner}_{repo}_actions_runs_{run_id}_artifacts
  • Tags: pipeline-v8
  • Deprecated: false
  • Description: 分页查询指定 Workflow Run 产生的所有制品,支持按创建时间排序。

Request Parameters

Name In Required Type Description
owner path yes string 仓库所属空间地址(组织或个人的地址path)
repo path yes string 仓库路径(path)
run_id path yes string 流水线运行id
access_token query no string 用户授权码
name query no string 制品名称过滤(模糊匹配)
sort query no string 排序字段,当前仅支持created
direction query no string 排序方向,asc 或 desc
page query no integer 当前页码
per_page query no integer 每页的项目数

Request Body

无。

Responses

200

  • Description: (empty)
  • Headers: 无
  • Content-Types: application/json

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"
}

原始 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"
  }
}

初步验收建议

  • 增加对应 API client/query 方法,保留 v8 路径。
  • 设计 agent-friendly 的 CLI 命令、帮助文本、JSON 输出和错误处理。
  • 单元测试覆盖参数映射、响应解析和错误路径。
  • 如做真实命令验证,只能使用 infra-test/* 仓库。
  • 不暴露或打印 token;文档中的 access_token 仅作为 API 参数记录,CLI 优先复用现有认证机制。
likedislike
AaflyingtoCollaborators
Jul 9 Added label: risk/mediumscope/api, status/triage,type/feature
AaflyingtoCollaborators
Jul 9 Associated milestone: Actions M2: Artifacts 管理
AaflyingtoCollaborators
Jul 9 Added label: featurescope/actions
AaflyingtoCollaborators
Jul 9 Removed label: feature
aflyingtoCollaborators
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 路由)。
likedislike
AaflyingtoCollaborators
Jul 10 Removed label: status/triage
AaflyingtoCollaborators
Jul 10 Added label: status/in-progress, status/verified
AaflyingtoCollaborators
Jul 10 Associated pull request
AaflyingtoCollaborators
Jul 10 Close issue
AaflyingtoCollaborators
Jul 10 Removed label: status/in-progress
AaflyingtoCollaborators
Jul 10 Removed label: status/verified
AaflyingtoCollaborators
Jul 10 Added label: status/merged