Create_check_run causes a duplicate check_run after pull_request

Hello,

I am following the tutorial on “Creating CI tests with the Checks API”
https://docs.github.com/en/developers/apps/guides/creating-ci-tests-with-the-checks-api

with one small change: I would like to create CI tests on pull requests from forks.

I have found that the tutorial is not built to handle pull requests at all.

  1. Pull requests are not an event I can subscribe to in my Github App preferences, so I had to go into my organization’s “Webhook” settings and enable the “pull request” checkbox there. And when I do receive the pull_request event, the JSON has no app install identifier. So I hardcoded it in my Github app.
  2. I modified the Ruby script in the tutorial to accept pull requests like this:
    # Create a new check run with the status queued
    def create_check_run

      logger.debug "creating check run"

      # The payload structure differs depending on whether a check run or a check suite event occurred.
      if @payload['check_run'] != nil 
        commit_hash = @payload['check_run']['head_sha']
      elsif @payload['check_suite'] != nil
        commit_hash = @payload['check_suite']['head_sha']
      elsif @payload['pull_request'] != nil
        commit_hash = @payload['pull_request']['head']['sha']
      end
      logger.debug "commit_hash: " + commit_hash

      @installation_client.create_check_run(
        # [String, Integer, Hash, Octokit Repository object] A GitHub repository.
        @payload['repository']['full_name'],
        # [String] The name of your check run.
        'P7 power usage average 90s after reset',
        # [String] The SHA of the commit to check 
        commit_hash, 
        # [Hash] 'Accept' header option, to avoid a warning about the API not being ready for production use.
        accept: 'application/vnd.github.v3+json'
      )
    end

when I submit this, I receive TWO check_run events to my application with the exact same payload. I am pretty sure these duplicates are coming from Github and not my Ruby script.
I have checked my Github app’s history and there is only one check_run event sent and I checked my smee.io proxy and there is only one check_run event sent. But I think smee does not reveal duplicates. My smee client shows a duplicate check_run event.

Is this a GIthub bug?