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

1

6

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.

Deanadeanda answered 29/1, 2021 at 10:55 Comment(0)
D
8

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
Disinclination answered 21/2, 2021 at 20:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.