dwardu
dwardu

Reputation: 633

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

I have been looking at the GitHub REST API and i have been trying to find out where I can find the endpoint to get the status of a workflow in my actions. The only way i can tell if it is passing or failing is by downloading the badge.svg.

Upvotes: 6

Views: 4092

Answers (1)

Bertrand Martel
Bertrand Martel

Reputation: 45362

You can use workflow run api :

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

[workflowID] can also be the filename, in the following example ci.yml :

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

Then you can get the first run using curl and jq :

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

output:

completed

Upvotes: 8

Related Questions