如何获取 Github 操作工作流的 Passing/Failing 状态?

How can i get the Passing/Failing status of a Github Action Workflow?

我一直在查看 GitHub REST API 并且我一直在尝试找出在哪里可以找到端点以获取我的操作中的工作流状态。我可以判断它是通过还是失败的唯一方法是下载 badge.svg.

您可以使用 workflow run api :

GET https://api.github.com/repos/[owner]/[repo]/actions/workflows/[workflowID]/runs

[workflowID]也可以是文件名,如下例ci.yml:

https://api.github.com/repos/bertrandmartel/tableau-scraping/actions/workflows/ci.yml/runs

然后你可以得到第一个 运行 使用 curljq :

curl -s "https://api.github.com/repos/bertrandmartel/tableau-scraping/actions/workflows/ci.yml/runs" | \
    jq -r '.workflow_runs[0].status'

输出:

completed