Skip to content

Conversation

@rschristian
Copy link
Member

@rschristian rschristian commented Aug 24, 2025

Re: #4891 (comment). My guinea pig is still testing this, but seems like it'll work. My guinea pig has confirmed it'll work.

TLDR: PR events, when coming from those who have maintainer rights, include a field called pull_requests that looks like this:

github.event.workflow_run.pull_requests

"pull_requests": [
  {
    "base": {
      "ref": "master",
      "repo": {
        "id": 918443277,
        "name": "debug__workflow_run-fork",
        "url": "https://api.github.com/repos/rschristian/debug__workflow_run-fork"
      },
      "sha": "8a91303965a6e8f6ceba7a9a54c631a60b6d7ce5"
    },
    "head": {
      "ref": "debug/event-fields",
      "repo": {
        "id": 918443277,
        "name": "debug__workflow_run-fork",
        "url": "https://api.github.com/repos/rschristian/debug__workflow_run-fork"
      },
      "sha": "6cbbe6a0d854cf3c4817f22560b3c4434ac65457"
    },
    "id": 2634577244,
    "number": 10,
    "url": "https://api.github.com/repos/rschristian/debug__workflow_run-fork/pulls/10"
  }
]

Forked repo, on the other hand, gets this:

"pull_requests": []

...which is lame & there are no other references to the base SHA anywhere else in the event payload. Alternatively, one would think they could use GitHub's API to query for PRs containing a commit, or just query the commit & get the PRs that include it, but these too don't work for unknown reasons when the commit comes from a fork.

Instead, we're using the owner+branch name, querying for all PRs on the repo that match, getting the latest result & extracting the base SHA from it. This is weird but GitHub's data doesn't give us a choice.

@coveralls
Copy link

coveralls commented Aug 24, 2025

Coverage Status

coverage: 99.535%. remained the same
when pulling bbadeba on ci/fix-pr-target
into 5dd6c09 on main.

@rschristian rschristian marked this pull request as ready for review August 28, 2025 17:26
@rschristian rschristian merged commit 027142c into main Aug 28, 2025
5 checks passed
@rschristian rschristian deleted the ci/fix-pr-target branch August 28, 2025 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants