You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用GitHub API根据指定Commit SHA获取构建产物?

获取指定Commit SHA的GitHub构建产物

已知目标Commit存在带构建产物的成功工作流运行记录,可按以下流程操作:

  • 获取对应工作流运行ID
    已通过以下命令筛选出该Commit对应的成功工作流运行ID:

    gh run list -b main -w ci \
      --json headSha,conclusion,databaseId \
      --jq ".[] | select(.headSha == \"21e6188608352ac2ed8e2d4c65e11ae2dbe20291\" and .conclusion == \"success\") \
      | .databaseId" \
      | jq --color-output
    
  • 下载构建产物
    拿到运行ID后,使用gh run download命令下载产物:

    # 将<RUN_ID>替换为上述命令输出的ID值
    gh run download <RUN_ID>
    
    • 若需下载特定产物,添加-n参数指定产物名称:

      gh run download <RUN_ID> -n <ARTIFACT_NAME>
      
    • 也可合并命令,自动获取ID并下载:

      gh run download $(gh run list -b main -w ci \
        --json headSha,conclusion,databaseId \
        --jq ".[] | select(.headSha == \"21e6188608352ac2ed8e2d4c65e11ae2dbe20291\" and .conclusion == \"success\") \
        | .databaseId")
      

内容的提问来源于stack exchange,提问作者sorin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 01:06:24