Agreed , this is would be very useful ! Working on a similar project that reacts to check_run events to launch runners via LXD. The associated runner labels are required to:
- Determine if the check_run is intended for Github hosted or self-hosted runners, else we end up spawning runners when not needed.
- If its self-hosted then we need labels to know where to route it.
I can think one way to do it through API but its not pretty:
- From the check_run event get the build name check_run.name and check_run.head_sha and check_run.check_suite.id
- Get unfinished workflow runs for the repo and search for one with matching check_suite_id. From that get the workflow_id
- Get workflow object and get the path
- Grab the workflow file for commit @head_sha
- Parse workflow yaml and get jobs. Find your matching job and pull out the runs-on
Not very efficient, 3 API calls just for labels. The job name is also not reliably stable. If running matrix builds the used variables are appended, easy enough to parse I guess.
If anyone knows simpler method, would love to know. Ideally labels should be inside check_run event.
Associated project: GitHub - jonans/lxdrunner: Run ephemeral self-hosted runners for GitHub Actions with LXD