How to reliably attach a check run to the current run


I’m working on a GitHub Actions to create annotations from a JSON file:

Unfortunately, and as far as I know, it’s not possible to create a check run and attach it to the current run.
For instance, let’s say that my action is running on the run id 123456 (, how can create a new check run and attach it to this run?

When creating a new create run using the API, it’s not possible to pass a run id.

I can use GitHub context to retrieve the sha, repo and owner but not the run id:

const ref = github.context.sha
const owner = github.context.repo.owner
const repo = github.context.repo.repo

To workaround this issue, some users are using listForRef to get the current check run:

  status: "in_progress"

But this approach seems fragile because I guess that the function could return more than one result or no result. The other drawback is that we are updating an existing check run where I want to create a new one.

Am I missing something?


I got a second bug report indicating that the check run is not associated to the pull request:

Any idea?

For reference, the source code is available at: