已关闭
feat(actions): 支持 列出仓库的 Artifacts API #439
aflyingto创建于  7月9日关闭于  7月10日
aflyingto成员
7月9日 创建

背景

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

API 摘要

  • 标题: 列出仓库的 Artifacts
  • Method: GET
  • Path: /api/v8/repos/{owner}/{repo}/actions/artifacts
  • Operation ID: get_api_v8_repos_{owner}_{repo}_actions_artifacts
  • Tags: pipeline-v8
  • Deprecated: false
  • Description: 分页查询仓库下的制品,支持按名称过滤及排序。

Request Parameters

Name In Required Type Description
owner path yes string 仓库所属空间地址(组织或个人的地址path)
repo path yes string 仓库路径(path)
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": "分页查询仓库下的制品,支持按名称过滤及排序。",
  "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"
  }
}

初步验收建议

  • 增加对应 API client/query 方法,保留 v8 路径。
  • 设计 agent-friendly 的 CLI 命令、帮助文本、JSON 输出和错误处理。
  • 单元测试覆盖参数映射、响应解析和错误路径。
  • 如做真实命令验证,只能使用 infra-test/* 仓库。
  • 不暴露或打印 token;文档中的 access_token 仅作为 API 参数记录,CLI 优先复用现有认证机制。
likedislike
Aaflyingto成员
7月9日 添加了label:risk/mediumscope/api, status/triage,type/feature
Aaflyingto成员
7月9日 关联了里程碑:Actions M2: Artifacts 管理
Aaflyingto成员
7月9日 添加了label:featurescope/actions
Aaflyingto成员
7月9日 删除了label:feature
aflyingto成员
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)。
likedislike
Aaflyingto成员
7月10日 删除了label:status/triage
Aaflyingto成员
7月10日 添加了label:status/in-progress, status/verified
Aaflyingto成员
7月10日 关联了pull request:feat(actions): add gc actions artifact list for repository artifacts
Aaflyingto成员
7月10日 关闭了 issue
Aaflyingto成员
7月10日 删除了label:status/in-progress
Aaflyingto成员
7月10日 删除了label:status/verified
Aaflyingto成员
7月10日 添加了label:status/merged
Aaflyingto成员
7月10日 关联了pull request:feat(actions): add --run flag to artifact list for run-scoped artifacts
Aaflyingto成员
7月10日 关联了pull request:feat(actions): add gc actions artifact view for artifact detail