--- title: "ADR 0013: How GitHub push and re-run events resolve their pull request" --- * Status: accepted * Code: [`pkg/provider/github/parse_payload.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/github/parse_payload.go) ## Context GitHub push and check re-run payloads do not reliably name the pull request they belong to, and the API that maps commit to pull request can lag behind a merge. ## Decision * `getPullRequestsWithCommit` retries with exponential backoff on an empty result, only for merge commits (committer email `noreply@github.com` or name `web-flow`), because GitHub may not have indexed the commit-to-PR association yet after a merge commit. After the last attempt an empty list is returned without an error. * A push event whose commit belongs to an open pull request is skipped when `SkipPushEventForPRCommits` is enabled, except for tag pushes. Otherwise the first associated pull request supplies `pull_request_number`. * A push to a branch whose `after` is the zero SHA is a branch deletion. It is refused with an error, because deletions are not handled. * For a re-run, a commit present in several open pull requests is an error (`selectSingleOpenPullRequest`, `selectSinglePullRequestFromPayload`) instead of picking the first: payload ordering must not decide which PR receives the run. When the commits API returns nothing, as it may for fork pull request commits, the open pull request listing is searched by head SHA. * The sender of a re-run is the user who clicked Re-run, and for a `synchronize` pull request event it is the pusher when known. Otherwise population would fall back to the pull request author, and a trusted maintainer updating a fork pull request would not authorize the run. * In `populateRunEventFromPullRequest` the default branch and URL come from the pull request base repository, never the head, so a fork cannot choose them. * A `/test` or `/cancel` comment naming a tag resolves the tag ref: an annotated tag (`tag` object) is dereferenced to its commit, a lightweight tag (`commit` object) already holds the commit SHA, and a tag object lookup on it would fail. ## Consequences * A commit shared by several open pull requests cannot be re-run through the check suite path until one is closed. * Merge commits can add backoff delay to push handling.