Merge a GitHub pull request
github_pr_mergeMerge a pull request with merge, squash, or rebase, checking a reviewed head SHA and handling stacked layers so merges match reviewed commits.
Instructions
Merge a pull request with merge, squash or rebase. Every pull request, stacked or not, merges through one GitHub request that this call follows until it ends. method may be left out when the repository allows only one; when it allows several, or the one asked is not allowed, the call fails saying which are. Pass head_sha, the commit that was reviewed, to merge only that: if new commits arrived the call fails with stale and merges nothing. The head merged is always the one read at the start. subject and body set the merge or squash commit's title and message; a rebase makes no merge commit, so they are refused with it. A closed pull request, a draft and one with conflicts are refused before anything is sent, and so is a merged one: it is left as it is, changed is false and nothing else merges. Whether the branch rules and required checks are met is GitHub's to enforce: a pull request they block, or one that is behind its base or unstable, is sent anyway and GitHub's refusal is returned. Nothing bypasses the rules, and a repository that requires a merge queue queues it (status enqueued). In a native stack, merging a layer also merges every open layer below it, each as its own commit, while the layers above stay open and GitHub retargets them. That is refused, listing the layers below, unless with_lower_layers is true; a lower layer that is a draft or in conflict is refused by name. subject and body apply to the named layer only. The call waits up to 45 seconds, reading the request every 3. If GitHub is still merging then, status is pending with a note: read the pull request later with github_pr_read view. The result lists the pull request and the layers taken along as read after the merge. delete_branch deletes the head branch of each pull request that merged, bottom to top, best effort and never failing the call: the default branch, a branch another open pull request is based on, one in a fork and one with new commits since the merge are kept, and branches reports each result. Merging closes the issues the pull request names, in other repositories too. A pull request is 12, #12, owner/repo#12 or its URL; a bare number means the working tree's repository, or repo.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pr | Yes | The pull request, as 12, #12, owner/repo#12 or its URL. | |
| body | No | The merge or squash commit's message. Not for rebase. For a stacked merge it applies to the named pull request only. | |
| repo | No | owner/name; defaults to the working tree's repository (its origin). Used for a bare number. | |
| method | No | How to merge: merge, squash or rebase. Optional when the repository allows only one; required when it allows several. | |
| subject | No | The merge or squash commit's title. Not for rebase. For a stacked merge it applies to the named pull request only. | |
| head_sha | No | Optional 40-character commit SHA the pull request was reviewed at. Fails with stale, merging nothing, if new commits arrived. | |
| delete_branch | No | Delete the head branch of each pull request that merged, best effort (default false). | |
| with_lower_layers | No | For a pull request in a stack: also merge the open layers below it, which merging it does anyway (default false: refuse and list them). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pr | Yes | ||
| repo | Yes | ||
| notes | Yes | What to know about the result; [] when nothing. | |
| errors | Yes | Failed steps, keyed by step (fields.<Field name>, blocked_by, kind, labels, milestone); {} when none. | |
| merged | Yes | The pull request and the open layers below it that the merge took along, bottom to top, as read after. | |
| method | Yes | The method of the merge request; null when the pull request was merged already and none was asked. | |
| status | Yes | merged; enqueued: in the merge queue; pending: GitHub is still merging when the wait ended; failed: GitHub could not merge it. | |
| changed | Yes | False when the pull request was merged already and nothing was sent. | |
| foreign | Yes | ||
| request | Yes | GitHub's ID of the merge request; null when none was made. | |
| branches | Yes | What became of each head branch; [] without delete_branch. |