Run a check suite on a PR merge commit

From the documentation and some questions here, I understood that GitHub Apps can’t start check suites or check runs on commits that don’t belong to the owner’s repository. This means that it is impossible to start a check suite or check run on a commit that belongs to a forked repository.

As described in “Checking mergeability of pull requests”, it is possible to obtain a test merge commit by reading a pull request and obtaining the SHA of the test merge commit. I tried to start a check suite on the merge commit, and it was created successfully. Unfortunately, the check suite didn’t generate any events and didn’t show up in the GitHub UI.

Is there any way at all to start a check run on a commit that represents either the latest state of the unmerged PR, or the latest merged state of the unmerged PR, or both?

EDIT I found out that it is possible to list the commits in a PR (possibly following paginations, if needed) and figure out the SHA of the last commit in the PR. Once the SHA of the last commit is determined, it is possible to start a check run on the commit, which will trigger the expected events. It is quite nice to perform these actions for PR events “opened”, “synchronized” (to react to new commits being pushed to the PR), and “reopened” (to trigger the check runs if a closed PR is reopened).

Glad that you found your own solution to this. I’m highlighting this in case anyone else stumbles across your question and has the same issue. Thank you for sharing it with us.