如何获取 Github 操作工作流程的通过/失败状态?

dwa*_*rdu 6 github github-api github-actions building-github-actions

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

Ber*_*tel 8

您可以使用工作流运行 api

GET https://api.github.com/repos/[owner]/[repo]/actions/workflows/[workflowID]/runs
Run Code Online (Sandbox Code Playgroud)

[workflowID]也可以是文件名,在以下示例中ci.yml

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

curl然后你可以使用和进行第一次运行jq

GET https://api.github.com/repos/[owner]/[repo]/actions/workflows/[workflowID]/runs
Run Code Online (Sandbox Code Playgroud)

输出:

completed
Run Code Online (Sandbox Code Playgroud)