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

如何获取指定RUN_ID的GitHub Actions工作流摘要?

获取指定RUN_ID的GitHub工作流摘要

用GH CLI快速获取

直接执行命令替换<RUN_ID>即可查看摘要:

gh run view <RUN_ID> --step-summary

要保存到文件:

gh run view <RUN_ID> --step-summary > summary.md

通过GitHub REST API获取

  1. 先获取目标运行的所有Job ID:
curl -H "Authorization: token YOUR_TOKEN" \
  "https://api.github.com/repos/OWNER/REPO/actions/runs/<RUN_ID>/jobs"

从返回的JSON里提取目标Job的id。

  1. 获取该Job的步骤详情,找到带summary_url的步骤:
curl -H "Authorization: token YOUR_TOKEN" \
  "https://api.github.com/repos/OWNER/REPO/actions/jobs/<JOB_ID>"

在steps数组中找到包含summary_url的条目,复制其路径。

  1. 请求该URL获取摘要内容:
curl -H "Authorization: token YOUR_TOKEN" \
  "https://api.github.com<摘要URL路径>"

在工作流中用github-script获取

如果是在另一个GitHub Actions工作流里获取,可使用actions/github-script:

- name: Fetch workflow summary
  uses: actions/github-script@v6
  with:
    script: |
      const targetRunId = 123456789; // 替换为目标RUN_ID
      const jobs = await github.rest.actions.listJobsForWorkflowRun({
        owner: context.repo.owner,
        repo: context.repo.repo,
        run_id: targetRunId
      });

      for (const job of jobs.data.jobs) {
        const jobDetails = await github.rest.actions.getJobForWorkflowRun({
          owner: context.repo.owner,
          repo: context.repo.repo,
          job_id: job.id
        });

        for (const step of jobDetails.data.steps) {
          if (step.summary_url) {
            const summaryRes = await github.request(step.summary_url);
            console.log("工作流摘要内容:\n", summaryRes.data);
            return summaryRes.data;
          }
        }
      }

内容的提问来源于stack exchange,提问作者Vitaly Karasik DevOps

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 04:27:15