Skip to content

steps/pull-requests ​

Read and update GitHub pull requests outside workflow code.

Wrap steps in a factory-owned "use step" file. Never call them directly from a workflow.

Interfaces ​

GitHubRepoRef ​

Identifies a GitHub repository by its owner and name.

Properties ​

PropertyTypeDescription
ownerstringThe GitHub organization or account that owns the repository.
repostringThe repository name.

Type Aliases ​

MergeOutcome ​

ts
type MergeOutcome = 
  | {
  mergeCommitSha: string | null;
  merged: true;
}
  | object & MergeRefusal;

What GitHub did, and when it did not, why — and whether asking again could change the answer, which is what decides between standing the commit down and leaving it merge-ready.

Type Declaration ​

ts
{
  mergeCommitSha: string | null;
  merged: true;
}
NameTypeDescription
mergeCommitShastring | nullThe merge commit, or null when GitHub has not reported it yet.
mergedtrueConfirms that GitHub reports the pull request merged.

object & MergeRefusal


OpenedPullRequest ​

ts
type OpenedPullRequest = PullRequestRef & object;

A newly opened or adopted pull request and its browser URL.

Type Declaration ​

NameTypeDescription
urlstringThe pull request's browser URL.

Variables ​

fetchPullRequestState ​

ts
const fetchPullRequestState: FetchPrState;

Read the pull request’s checks, reviews, and open review threads.

Functions ​

commentOnPullRequest() ​

ts
function commentOnPullRequest(pr, body): Promise<{
  id: number;
}>;

Post a comment on the pull request conversation and return its id.

Parameters ​

ParameterType
prPullRequestRef
bodystring

Returns ​

Promise<{ id: number; }>


markPullRequestReady() ​

ts
function markPullRequestReady(pr): Promise<PullRequestSnapshot>;

Mark a draft pull request ready and return its freshly read state.

Parameters ​

ParameterType
prPullRequestRef

Returns ​

Promise<PullRequestSnapshot>


mergePullRequest() ​

ts
function mergePullRequest(
   pr, 
   expectedHeadSha, 
policy): Promise<MergeOutcome>;

Merge the pull request with the configured method, pinned to the head the caller judged ready.

The title is re-read here rather than carried in from describePullRequest: a reviewer who corrects it — to satisfy a conventional-commit check on the target repo, usually — does so between the pull request opening and this merge, and a title captured at open time would ship the one they corrected away. After any ambiguous answer the pull request is read again, and this reports merged only if GitHub says so.

Parameters ​

ParameterTypeDescription
prPullRequestRef-
expectedHeadShastring-
policy{ approval: | { kind: "review"; } | { kind: "label"; name: string; }; by: "jigs" | "human"; method: "squash" | "merge" | "rebase"; }-
policy.approval| { kind: "review"; } | { kind: "label"; name: string; }The signal that authorizes an automatic merge.
policy.by"jigs" | "human"Whether jigs merges an eligible pull request or waits for a person to merge it.
policy.method"squash" | "merge" | "rebase"The GitHub merge method to use when jigs performs the merge.

Returns ​

Promise<MergeOutcome>


openPullRequest() ​

ts
function openPullRequest(request): Promise<OpenedPullRequest>;

Open a pull request from the working branch into the base branch.

The lookup comes first because this is one step: a create that succeeded before the assignment failed, or whose response was lost, leaves a pull request GitHub will refuse to open twice. The retry adopts that pull request and re-attempts only what did not finish.

Parameters ​

ParameterType
request{ base: string; body: string; draft?: boolean; head: string; repo: GitHubRepoRef; title: string; }
request.basestring
request.bodystring
request.draft?boolean
request.headstring
request.repoGitHubRepoRef
request.titlestring

Returns ​

Promise<OpenedPullRequest>


replyToPullRequestReviewThread() ​

ts
function replyToPullRequestReviewThread(
   pr, 
   rootId, 
   body): Promise<{
  id: number;
}>;

Reply to a review thread and return the posted comment id.

Parameters ​

ParameterType
prPullRequestRef
rootIdnumber
bodystring

Returns ​

Promise<{ id: number; }>


resolveMergePolicy() ​

ts
function resolveMergePolicy(binding): Promise<{
  approval:   | {
     kind: "review";
   }
     | {
     kind: "label";
     name: string;
   };
  by: "jigs" | "human";
  method: "squash" | "merge" | "rebase";
}>;

Read the effective merge policy for a factory binding.

Parameters ​

ParameterType
bindingstring

Returns ​

Promise<{ approval: | { kind: "review"; } | { kind: "label"; name: string; }; by: "jigs" | "human"; method: "squash" | "merge" | "rebase"; }>


resolveRepository() ​

ts
function resolveRepository(binding): Promise<GitHubRepoRef>;

Find the GitHub repository configured for a binding.

Parameters ​

ParameterType
bindingstring

Returns ​

Promise<GitHubRepoRef>


reviewPullRequest() ​

ts
function reviewPullRequest(pr, review): Promise<{
  id: number;
}>;

Post a pull request review and return its id. GitHub refuses an approval from the pull request's own author with 422 Unprocessable Entity; Jigs lets GitHub's GithubApiError surface unchanged.

Parameters ​

ParameterType
prPullRequestRef
reviewPullRequestReviewRequest

Returns ​

Promise<{ id: number; }>

Released under the MIT License.