Skip to content

GitHub.Pull Request reference

Source: packages/github/src/CreatePullRequest.ts

Open a pull request (pulls.create). The head branch must already exist; pushing commits to it is up to the caller.

Provide GitHub.CreatePullRequestHttp on a Worker or Function, or GitHub.CreatePullRequestLocal on an Action.

CreatePullRequest: Opening Pull Requests at Runtime

Section titled “CreatePullRequest: Opening Pull Requests at Runtime”
const createPullRequest = yield* GitHub.CreatePullRequest(yield* Repo);
const pull = yield* createPullRequest({
title: "fix: typo in README",
head: "fix/readme-typo",
base: "main",
body: "Closes #7.",
});

Source: packages/github/src/CreatePullRequestHttp.ts Kind: Layer · Provides: GitHub.CreatePullRequest

Token-backed implementation of CreatePullRequest. Provide it on a Worker or Function: it captures a GitHub.PersonalAccessToken for the host and binds the token and the repository into it.

Source: packages/github/src/CreatePullRequestLocal.ts Kind: Layer · Provides: GitHub.CreatePullRequest

Implementation of CreatePullRequest with the provider’s current credentials. Provide it on an Action or another deploy-time Effect.

Source: packages/github/src/CreatePullRequestReview.ts

Submit a pull request review (pulls.createReview): a body, an event verdict (APPROVE, REQUEST_CHANGES or COMMENT) and inline comments on diff lines, in one submission.

Provide GitHub.CreatePullRequestReviewHttp on a Worker or Function, or GitHub.CreatePullRequestReviewLocal on an Action.

CreatePullRequestReview: Reviewing Pull Requests at Runtime

Section titled “CreatePullRequestReview: Reviewing Pull Requests at Runtime”
const createReview = yield* GitHub.CreatePullRequestReview(yield* Repo);
yield* createReview({
pull_number: 9,
event: "REQUEST_CHANGES",
body: "One problem, inline.",
comments: [{ path: "src/index.ts", line: 42, body: "Off by one." }],
});

Source: packages/github/src/CreatePullRequestReviewHttp.ts Kind: Layer · Provides: GitHub.CreatePullRequestReview

Token-backed implementation of CreatePullRequestReview. Provide it on a Worker or Function: it captures a GitHub.PersonalAccessToken for the host and binds the token and the repository into it.

Source: packages/github/src/CreatePullRequestReviewLocal.ts Kind: Layer · Provides: GitHub.CreatePullRequestReview

Implementation of CreatePullRequestReview with the provider’s current credentials. Provide it on an Action or another deploy-time Effect.

Source: packages/github/src/GetPullRequest.ts

Get a pull request by number (pulls.get). Like the API, accept selects the media type: application/vnd.github.diff or application/vnd.github.patch return the diff or patch text instead of the JSON object.

Provide GitHub.GetPullRequestHttp on a Worker or Function, or GitHub.GetPullRequestLocal on an Action.

GetPullRequest: Reading Pull Requests at Runtime

Section titled “GetPullRequest: Reading Pull Requests at Runtime”
const getPullRequest = yield* GitHub.GetPullRequest(yield* Repo);
const pull = yield* getPullRequest({ pull_number: 9 });
const diff = yield* getPullRequest({
pull_number: 9,
accept: "application/vnd.github.diff",
});

Source: packages/github/src/GetPullRequestHttp.ts Kind: Layer · Provides: GitHub.GetPullRequest

Token-backed implementation of GetPullRequest. Provide it on a Worker or Function: it captures a GitHub.PersonalAccessToken for the host and binds the token and the repository into it.

Source: packages/github/src/GetPullRequestLocal.ts Kind: Layer · Provides: GitHub.GetPullRequest

Implementation of GetPullRequest with the provider’s current credentials. Provide it on an Action or another deploy-time Effect.

Source: packages/github/src/ListPullRequestFiles.ts

List one page of the files a pull request changes (pulls.listFiles), each with its status, line counts and patch. Unlike GetPullRequest with format: "diff", it pages through changes of any size (up to 3000 files).

Provide GitHub.ListPullRequestFilesHttp on a Worker or Function, or GitHub.ListPullRequestFilesLocal on an Action.

ListPullRequestFiles: Listing Changed Files at Runtime

Section titled “ListPullRequestFiles: Listing Changed Files at Runtime”
const listFiles = yield* GitHub.ListPullRequestFiles(yield* Repo);
const files = yield* listFiles({ pull_number: 9, per_page: 100 });
const paths = files.map((file) => file.filename);

Source: packages/github/src/ListPullRequestFilesHttp.ts Kind: Layer · Provides: GitHub.ListPullRequestFiles

Token-backed implementation of ListPullRequestFiles. Provide it on a Worker or Function: it captures a GitHub.PersonalAccessToken for the host and binds the token and the repository into it.

Source: packages/github/src/ListPullRequestFilesLocal.ts Kind: Layer · Provides: GitHub.ListPullRequestFiles

Implementation of ListPullRequestFiles with the provider’s current credentials. Provide it on an Action or another deploy-time Effect.

Source: packages/github/src/ListPullRequestReviewComments.ts

List one page of a pull request’s inline review comments (pulls.listReviewComments), each anchored to a path and line of the diff.

Provide GitHub.ListPullRequestReviewCommentsHttp on a Worker or Function, or GitHub.ListPullRequestReviewCommentsLocal on an Action.

ListPullRequestReviewComments: Listing Review Comments at Runtime

Section titled “ListPullRequestReviewComments: Listing Review Comments at Runtime”
const listReviewComments = yield* GitHub.ListPullRequestReviewComments(yield* Repo);
const comments = yield* listReviewComments({ pull_number: 9, per_page: 100 });

Source: packages/github/src/ListPullRequestReviewCommentsHttp.ts Kind: Layer · Provides: GitHub.ListPullRequestReviewComments

Token-backed implementation of ListPullRequestReviewComments. Provide it on a Worker or Function: it captures a GitHub.PersonalAccessToken for the host and binds the token and the repository into it.

Source: packages/github/src/ListPullRequestReviewCommentsLocal.ts Kind: Layer · Provides: GitHub.ListPullRequestReviewComments

Implementation of ListPullRequestReviewComments with the provider’s current credentials. Provide it on an Action or another deploy-time Effect.

Source: packages/github/src/ListPullRequestReviews.ts

List one page of a pull request’s reviews (pulls.listReviews).

Provide GitHub.ListPullRequestReviewsHttp on a Worker or Function, or GitHub.ListPullRequestReviewsLocal on an Action.

ListPullRequestReviews: Listing Reviews at Runtime

Section titled “ListPullRequestReviews: Listing Reviews at Runtime”
const listReviews = yield* GitHub.ListPullRequestReviews(yield* Repo);
const reviews = yield* listReviews({ pull_number: 9 });
const approved = reviews.some((review) => review.state === "APPROVED");

Source: packages/github/src/ListPullRequestReviewsHttp.ts Kind: Layer · Provides: GitHub.ListPullRequestReviews

Token-backed implementation of ListPullRequestReviews. Provide it on a Worker or Function: it captures a GitHub.PersonalAccessToken for the host and binds the token and the repository into it.

Source: packages/github/src/ListPullRequestReviewsLocal.ts Kind: Layer · Provides: GitHub.ListPullRequestReviews

Implementation of ListPullRequestReviews with the provider’s current credentials. Provide it on an Action or another deploy-time Effect.

Source: packages/github/src/ListPullRequests.ts

List one page of the repository’s pull requests (pulls.list).

Provide GitHub.ListPullRequestsHttp on a Worker or Function, or GitHub.ListPullRequestsLocal on an Action.

ListPullRequests: Listing Pull Requests at Runtime

Section titled “ListPullRequests: Listing Pull Requests at Runtime”
const listPullRequests = yield* GitHub.ListPullRequests(yield* Repo);
const open = yield* listPullRequests({ state: "open", base: "main" });

Source: packages/github/src/ListPullRequestsHttp.ts Kind: Layer · Provides: GitHub.ListPullRequests

Token-backed implementation of ListPullRequests. Provide it on a Worker or Function: it captures a GitHub.PersonalAccessToken for the host and binds the token and the repository into it.

Source: packages/github/src/ListPullRequestsLocal.ts Kind: Layer · Provides: GitHub.ListPullRequests

Implementation of ListPullRequests with the provider’s current credentials. Provide it on an Action or another deploy-time Effect.

Source: packages/github/src/MergePullRequest.ts

Merge a pull request (pulls.merge). Gate it yourself, e.g. on an approval from ListPullRequestReviews.

Provide GitHub.MergePullRequestHttp on a Worker or Function, or GitHub.MergePullRequestLocal on an Action.

MergePullRequest: Merging Pull Requests at Runtime

Section titled “MergePullRequest: Merging Pull Requests at Runtime”
const listReviews = yield* GitHub.ListPullRequestReviews(yield* Repo);
const mergePullRequest = yield* GitHub.MergePullRequest(yield* Repo);
const reviews = yield* listReviews({ pull_number: 9 });
if (reviews.some((review) => review.state === "APPROVED")) {
yield* mergePullRequest({ pull_number: 9, merge_method: "squash" });
}

Source: packages/github/src/MergePullRequestHttp.ts Kind: Layer · Provides: GitHub.MergePullRequest

Token-backed implementation of MergePullRequest. Provide it on a Worker or Function: it captures a GitHub.PersonalAccessToken for the host and binds the token and the repository into it.

Source: packages/github/src/MergePullRequestLocal.ts Kind: Layer · Provides: GitHub.MergePullRequest

Implementation of MergePullRequest with the provider’s current credentials. Provide it on an Action or another deploy-time Effect.

Source: packages/github/src/PullRequest.ts

A GitHub pull request.

PullRequest manages the lifecycle of a pull request in a repository. PRs are created on the first deploy and updated in place on subsequent deploys when properties change. By default, pull requests are retained on destruction to preserve history — set destroy() to opt in to closure.

Authentication is resolved via the GitHub Credentials service supplied by GitHub.providers() (env, stored PAT, gh CLI, or OAuth). The token needs repo scope for private repositories or public_repo for public ones.

Create a Basic Pull Request

const pr = yield* GitHub.PullRequest("feature-pr", {
owner: "my-org",
repository: "my-repo",
title: "Add new feature",
body: "## Changes\n\nThis PR adds...",
head: "feature-branch",
base: "main",
})

Draft Pull Request with Reviewers

const pr = yield* GitHub.PullRequest("draft-pr", {
owner: "my-org",
repository: "my-repo",
title: "WIP: New feature",
body: "Work in progress...",
head: "feature-branch",
base: "main",
draft: true,
reviewers: ["reviewer1", "reviewer2"],
teamReviewers: ["platform-team"],
})

Deploy with the same logical ID and different properties to update the existing PR in place rather than creating a new one.

const pr = yield* GitHub.PullRequest("completed-pr", {
owner: "my-org",
repository: "my-repo",
title: "Add new feature",
body: "Completed and ready to merge.",
head: "feature-branch",
base: "main",
state: "closed",
})

PullRequest: Pull Request with Labels and Milestone

Section titled “PullRequest: Pull Request with Labels and Milestone”
const pr = yield* GitHub.PullRequest("release-pr", {
owner: "my-org",
repository: "my-repo",
title: "Release v1.0",
body: "Release notes...",
head: "release-1.0",
base: "main",
labels: ["release", "v1.0"],
milestone: 1,
})

PullRequest: Infrastructure Deployment PRs

Section titled “PullRequest: Infrastructure Deployment PRs”

A common pattern is creating PRs for infrastructure changes that require review before merging.

yield* GitHub.PullRequest("infra-update", {
owner: "my-org",
repository: "my-repo",
title: "Update infrastructure configuration",
body: Output.interpolate`
## Infrastructure Changes
**Database:** ${database.endpoint}
**Cache:** ${cache.endpoint}
Requires approval before deployment.
`,
head: "infra-updates",
base: "main",
labels: ["infrastructure"],
reviewers: ["infrastructure-lead"],
})