Accessing `runs-on` labels from `check_run` event

Hi,

I am working on implementing automatic / scalable / on-demand self-hosted runners. The solution we are using is very similar to this solution:

  1. Subscribe to the check_run event
  2. If the check run isn’t started 60 seconds later, launch a self-hosted runner

Unfortunately, the event does not contain information about the runs-on labels. Additional API calls are needed in order to determine the presence of the self-hosted label, as well as which OS we’re supposed to launch.

This is the shortest route to the information I need that I was able to dig out:

  1. In the event, grab the check_run_id
  2. Call actions/job with the check_run_id. Retrieve the workflow_run_id and the job’s name.
    • Is it documented that the check_run_id is the same as the workflow_run_id? source.
    • It would be nice to have the job’s key in addition of the name, so that we can access the job item without iterating the jobs in the action code (step 7 below)
  3. Call actions/workflow_runs with the workflow_run_id. Retrieve the workflow_id.
  4. Call actions/workflows with the workflow_id. Retrieve the path attribute.
  5. Call repo/contents with the path to get the action’s code.
  6. Decode/parse the action file.
  7. List the jobs[...] from the code, find the one where the name matches the name from the actions/job response, and retrieve runs-on attribute from it.

Am I going through unnecessary steps? Is this information more readily available somewhere else?

1 Like

After some more testing, I realize that filtering the check_run events to action: requested gives me more information, and enables a simpler sequence:

  1. in the event, grab check_run_id and workflow['path']
  2. Call actions/job with the check_run_id and grab the job['name']
  3. Resume with step 5 from the original solution

This eliminates 2 API calls, but doesn’t really solve the whole “labels” and “what am I launching” question because I expect complications when I’ll have to determine labels for a run matrix.

1 Like