Annotations not working on pull_request

I am working on an action that turns Xcode compile warnings and errors into annotations.

This Action works well when I use it in a workflow that is triggered by a push to the main branch. But when it is triggered by a pull_request the annotations do not show up. The workflow executes, I see the correct annotation in a debug log and the call to add the annotations to the check run is good. No annotations are shown though.

What do I miss here? Are PRs special wrt annotations and/or check runs?

Here is the pull request:

And this is a regular commit to main:

The first has no annotations and no sign of the check. The latter works as I would expect.

@st3fan,

In the docs about the Checks API, I noticed the following description:

Note: The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty pull_requests array.

When the workflow runs on pull request, the commit SHA (github.sha) is the last merge commit on the PR merge branch (refs/pull/:prNumber/merge). It is not a commit that has been pushed into the repository.
At this time, you should specify the latest commit on the head branch (source branch) of the PR as the head_sha of the API. To get the head SHA, you can use the expression ${{ github.event.pull_request.head.sha }}.

I’ll close this thread because I think in the end I was simply testing the wrong thing. My mistake.