4

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.

dwardu
  • 573
  • 6
  • 22

1 Answers1

7

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
Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159