follow progress of a workflow called from the API

Is there a way to get the progress of a workflow from the API?

E.g. I call a workflow with this command:

api.github/repos/myuser/myrepo/dispatches

the process start but I don’t get any feedback. Would be great to get a process ID and be able to request the API to know the current progress of this process.

Is there anyway to achieve this?

2 Likes

I see that we can list all workflow runs for a workflow https://developer.github.com/v3/actions/workflow_runs/#list-workflow-runs

But I am still missing run_id from the job since dispatch doesn’t return anything.

Not every API will return a Response body/content when executing completed, some APIs only return a status code (such as 200 OK , 204 Created ).
The API in your case is used to create a repository dispatch event to trigger a workflow run, when executing completed, this API will only return a status code and No Response Content.
If you execute the API on a client (such as Postman), you can directly see the status code and Response body on the client UI.
If you execute the API in the workflow, you can try using Invoke-WebRequest to execute the API and get the status code. In your your case, it will return 204 if the API completed successfully.

$response = Invoke-WebRequest -Uri $uri -Headers $headers -Body $body -Method POST
$StatusCode = $Response.StatusCode
echo $StatusCode

 If an API has Response body returned, you can try using Invoke-RestMethod to execute the API and get Response body.

$response = Invoke-RestMethod -Uri $uri -Headers $headers -Body $body -Method POST
$response | ConvertTo-Json

I have the same question. This response doesn’t seem to have addressed the original question. The question assumes that we know that POST api.github.com/repos/myuser/myrepo/dispatches doesn’t provide the workflow run id, and is asking if, given that limitation, there is a best-practice for tracking the status of the run via Github’s api.