1. Packages
  2. Github Provider
  3. API Docs
  4. getRepositoryPullRequests
GitHub v6.7.0 published on Friday, Feb 28, 2025 by Pulumi

github.getRepositoryPullRequests

Explore with Pulumi AI

Use this data source to retrieve information about multiple GitHub Pull Requests in a repository.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";

const example = github.getRepositoryPullRequests({
    baseRepository: "example-repository",
    baseRef: "main",
    sortBy: "updated",
    sortDirection: "desc",
    state: "open",
});
Copy
import pulumi
import pulumi_github as github

example = github.get_repository_pull_requests(base_repository="example-repository",
    base_ref="main",
    sort_by="updated",
    sort_direction="desc",
    state="open")
Copy
package main

import (
	"github.com/pulumi/pulumi-github/sdk/v6/go/github"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := github.LookupRepositoryPullRequests(ctx, &github.LookupRepositoryPullRequestsArgs{
			BaseRepository: "example-repository",
			BaseRef:        pulumi.StringRef("main"),
			SortBy:         pulumi.StringRef("updated"),
			SortDirection:  pulumi.StringRef("desc"),
			State:          pulumi.StringRef("open"),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Github = Pulumi.Github;

return await Deployment.RunAsync(() => 
{
    var example = Github.GetRepositoryPullRequests.Invoke(new()
    {
        BaseRepository = "example-repository",
        BaseRef = "main",
        SortBy = "updated",
        SortDirection = "desc",
        State = "open",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.github.GithubFunctions;
import com.pulumi.github.inputs.GetRepositoryPullRequestsArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var example = GithubFunctions.getRepositoryPullRequests(GetRepositoryPullRequestsArgs.builder()
            .baseRepository("example-repository")
            .baseRef("main")
            .sortBy("updated")
            .sortDirection("desc")
            .state("open")
            .build());

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: github:getRepositoryPullRequests
      arguments:
        baseRepository: example-repository
        baseRef: main
        sortBy: updated
        sortDirection: desc
        state: open
Copy

Using getRepositoryPullRequests

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getRepositoryPullRequests(args: GetRepositoryPullRequestsArgs, opts?: InvokeOptions): Promise<GetRepositoryPullRequestsResult>
function getRepositoryPullRequestsOutput(args: GetRepositoryPullRequestsOutputArgs, opts?: InvokeOptions): Output<GetRepositoryPullRequestsResult>
Copy
def get_repository_pull_requests(base_ref: Optional[str] = None,
                                 base_repository: Optional[str] = None,
                                 head_ref: Optional[str] = None,
                                 owner: Optional[str] = None,
                                 sort_by: Optional[str] = None,
                                 sort_direction: Optional[str] = None,
                                 state: Optional[str] = None,
                                 opts: Optional[InvokeOptions] = None) -> GetRepositoryPullRequestsResult
def get_repository_pull_requests_output(base_ref: Optional[pulumi.Input[str]] = None,
                                 base_repository: Optional[pulumi.Input[str]] = None,
                                 head_ref: Optional[pulumi.Input[str]] = None,
                                 owner: Optional[pulumi.Input[str]] = None,
                                 sort_by: Optional[pulumi.Input[str]] = None,
                                 sort_direction: Optional[pulumi.Input[str]] = None,
                                 state: Optional[pulumi.Input[str]] = None,
                                 opts: Optional[InvokeOptions] = None) -> Output[GetRepositoryPullRequestsResult]
Copy
func LookupRepositoryPullRequests(ctx *Context, args *LookupRepositoryPullRequestsArgs, opts ...InvokeOption) (*LookupRepositoryPullRequestsResult, error)
func LookupRepositoryPullRequestsOutput(ctx *Context, args *LookupRepositoryPullRequestsOutputArgs, opts ...InvokeOption) LookupRepositoryPullRequestsResultOutput
Copy

> Note: This function is named LookupRepositoryPullRequests in the Go SDK.

public static class GetRepositoryPullRequests 
{
    public static Task<GetRepositoryPullRequestsResult> InvokeAsync(GetRepositoryPullRequestsArgs args, InvokeOptions? opts = null)
    public static Output<GetRepositoryPullRequestsResult> Invoke(GetRepositoryPullRequestsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetRepositoryPullRequestsResult> getRepositoryPullRequests(GetRepositoryPullRequestsArgs args, InvokeOptions options)
public static Output<GetRepositoryPullRequestsResult> getRepositoryPullRequests(GetRepositoryPullRequestsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: github:index/getRepositoryPullRequests:getRepositoryPullRequests
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

BaseRepository This property is required. string
Name of the base repository to retrieve the Pull Requests from.
BaseRef string
If set, filters Pull Requests by base branch name.
HeadRef string
If set, filters Pull Requests by head user or head organization and branch name in the format of "user:ref-name" or "organization:ref-name". For example: "github:new-script-format" or "octocat:test-branch".
Owner string
Owner of the repository. If not provided, the provider's default owner is used.
SortBy string
If set, indicates what to sort results by. Can be either "created", "updated", "popularity" (comment count) or "long-running" (age, filtering by pulls updated in the last month). Default: "created".
SortDirection string
If set, controls the direction of the sort. Can be either "asc" or "desc". Default: "asc".
State string
If set, filters Pull Requests by state. Can be "open", "closed", or "all". Default: "open".
BaseRepository This property is required. string
Name of the base repository to retrieve the Pull Requests from.
BaseRef string
If set, filters Pull Requests by base branch name.
HeadRef string
If set, filters Pull Requests by head user or head organization and branch name in the format of "user:ref-name" or "organization:ref-name". For example: "github:new-script-format" or "octocat:test-branch".
Owner string
Owner of the repository. If not provided, the provider's default owner is used.
SortBy string
If set, indicates what to sort results by. Can be either "created", "updated", "popularity" (comment count) or "long-running" (age, filtering by pulls updated in the last month). Default: "created".
SortDirection string
If set, controls the direction of the sort. Can be either "asc" or "desc". Default: "asc".
State string
If set, filters Pull Requests by state. Can be "open", "closed", or "all". Default: "open".
baseRepository This property is required. String
Name of the base repository to retrieve the Pull Requests from.
baseRef String
If set, filters Pull Requests by base branch name.
headRef String
If set, filters Pull Requests by head user or head organization and branch name in the format of "user:ref-name" or "organization:ref-name". For example: "github:new-script-format" or "octocat:test-branch".
owner String
Owner of the repository. If not provided, the provider's default owner is used.
sortBy String
If set, indicates what to sort results by. Can be either "created", "updated", "popularity" (comment count) or "long-running" (age, filtering by pulls updated in the last month). Default: "created".
sortDirection String
If set, controls the direction of the sort. Can be either "asc" or "desc". Default: "asc".
state String
If set, filters Pull Requests by state. Can be "open", "closed", or "all". Default: "open".
baseRepository This property is required. string
Name of the base repository to retrieve the Pull Requests from.
baseRef string
If set, filters Pull Requests by base branch name.
headRef string
If set, filters Pull Requests by head user or head organization and branch name in the format of "user:ref-name" or "organization:ref-name". For example: "github:new-script-format" or "octocat:test-branch".
owner string
Owner of the repository. If not provided, the provider's default owner is used.
sortBy string
If set, indicates what to sort results by. Can be either "created", "updated", "popularity" (comment count) or "long-running" (age, filtering by pulls updated in the last month). Default: "created".
sortDirection string
If set, controls the direction of the sort. Can be either "asc" or "desc". Default: "asc".
state string
If set, filters Pull Requests by state. Can be "open", "closed", or "all". Default: "open".
base_repository This property is required. str
Name of the base repository to retrieve the Pull Requests from.
base_ref str
If set, filters Pull Requests by base branch name.
head_ref str
If set, filters Pull Requests by head user or head organization and branch name in the format of "user:ref-name" or "organization:ref-name". For example: "github:new-script-format" or "octocat:test-branch".
owner str
Owner of the repository. If not provided, the provider's default owner is used.
sort_by str
If set, indicates what to sort results by. Can be either "created", "updated", "popularity" (comment count) or "long-running" (age, filtering by pulls updated in the last month). Default: "created".
sort_direction str
If set, controls the direction of the sort. Can be either "asc" or "desc". Default: "asc".
state str
If set, filters Pull Requests by state. Can be "open", "closed", or "all". Default: "open".
baseRepository This property is required. String
Name of the base repository to retrieve the Pull Requests from.
baseRef String
If set, filters Pull Requests by base branch name.
headRef String
If set, filters Pull Requests by head user or head organization and branch name in the format of "user:ref-name" or "organization:ref-name". For example: "github:new-script-format" or "octocat:test-branch".
owner String
Owner of the repository. If not provided, the provider's default owner is used.
sortBy String
If set, indicates what to sort results by. Can be either "created", "updated", "popularity" (comment count) or "long-running" (age, filtering by pulls updated in the last month). Default: "created".
sortDirection String
If set, controls the direction of the sort. Can be either "asc" or "desc". Default: "asc".
state String
If set, filters Pull Requests by state. Can be "open", "closed", or "all". Default: "open".

getRepositoryPullRequests Result

The following output properties are available:

BaseRepository string
Id string
The provider-assigned unique ID for this managed resource.
Results List<GetRepositoryPullRequestsResult>
Collection of Pull Requests matching the filters. Each of the results conforms to the following scheme:
BaseRef string
Name of the ref (branch) of the Pull Request base.
HeadRef string
Value of the Pull Request HEAD reference.
Owner string
SortBy string
SortDirection string
State string
the current Pull Request state - can be "open", "closed" or "merged".
BaseRepository string
Id string
The provider-assigned unique ID for this managed resource.
Results []GetRepositoryPullRequestsResult
Collection of Pull Requests matching the filters. Each of the results conforms to the following scheme:
BaseRef string
Name of the ref (branch) of the Pull Request base.
HeadRef string
Value of the Pull Request HEAD reference.
Owner string
SortBy string
SortDirection string
State string
the current Pull Request state - can be "open", "closed" or "merged".
baseRepository String
id String
The provider-assigned unique ID for this managed resource.
results List<GetRepositoryPullRequestsResult>
Collection of Pull Requests matching the filters. Each of the results conforms to the following scheme:
baseRef String
Name of the ref (branch) of the Pull Request base.
headRef String
Value of the Pull Request HEAD reference.
owner String
sortBy String
sortDirection String
state String
the current Pull Request state - can be "open", "closed" or "merged".
baseRepository string
id string
The provider-assigned unique ID for this managed resource.
results GetRepositoryPullRequestsResult[]
Collection of Pull Requests matching the filters. Each of the results conforms to the following scheme:
baseRef string
Name of the ref (branch) of the Pull Request base.
headRef string
Value of the Pull Request HEAD reference.
owner string
sortBy string
sortDirection string
state string
the current Pull Request state - can be "open", "closed" or "merged".
base_repository str
id str
The provider-assigned unique ID for this managed resource.
results Sequence[GetRepositoryPullRequestsResult]
Collection of Pull Requests matching the filters. Each of the results conforms to the following scheme:
base_ref str
Name of the ref (branch) of the Pull Request base.
head_ref str
Value of the Pull Request HEAD reference.
owner str
sort_by str
sort_direction str
state str
the current Pull Request state - can be "open", "closed" or "merged".
baseRepository String
id String
The provider-assigned unique ID for this managed resource.
results List<Property Map>
Collection of Pull Requests matching the filters. Each of the results conforms to the following scheme:
baseRef String
Name of the ref (branch) of the Pull Request base.
headRef String
Value of the Pull Request HEAD reference.
owner String
sortBy String
sortDirection String
state String
the current Pull Request state - can be "open", "closed" or "merged".

Supporting Types

GetRepositoryPullRequestsResult

BaseRef This property is required. string
If set, filters Pull Requests by base branch name.
BaseSha This property is required. string
Head commit SHA of the Pull Request base.
Body This property is required. string
Body of the Pull Request.
Draft This property is required. bool
Indicates Whether this Pull Request is a draft.
HeadOwner This property is required. string
Owner of the Pull Request head repository.
HeadRef This property is required. string
If set, filters Pull Requests by head user or head organization and branch name in the format of "user:ref-name" or "organization:ref-name". For example: "github:new-script-format" or "octocat:test-branch".
HeadRepository This property is required. string
Name of the Pull Request head repository.
HeadSha This property is required. string
Head commit SHA of the Pull Request head.
Labels This property is required. List<string>
List of label names set on the Pull Request.
MaintainerCanModify This property is required. bool
Indicates whether the base repository maintainers can modify the Pull Request.
Number This property is required. int
The number of the Pull Request within the repository.
OpenedAt This property is required. int
Unix timestamp indicating the Pull Request creation time.
OpenedBy This property is required. string
GitHub login of the user who opened the Pull Request.
State This property is required. string
If set, filters Pull Requests by state. Can be "open", "closed", or "all". Default: "open".
Title This property is required. string
The title of the Pull Request.
UpdatedAt This property is required. int
The timestamp of the last Pull Request update.
BaseRef This property is required. string
If set, filters Pull Requests by base branch name.
BaseSha This property is required. string
Head commit SHA of the Pull Request base.
Body This property is required. string
Body of the Pull Request.
Draft This property is required. bool
Indicates Whether this Pull Request is a draft.
HeadOwner This property is required. string
Owner of the Pull Request head repository.
HeadRef This property is required. string
If set, filters Pull Requests by head user or head organization and branch name in the format of "user:ref-name" or "organization:ref-name". For example: "github:new-script-format" or "octocat:test-branch".
HeadRepository This property is required. string
Name of the Pull Request head repository.
HeadSha This property is required. string
Head commit SHA of the Pull Request head.
Labels This property is required. []string
List of label names set on the Pull Request.
MaintainerCanModify This property is required. bool
Indicates whether the base repository maintainers can modify the Pull Request.
Number This property is required. int
The number of the Pull Request within the repository.
OpenedAt This property is required. int
Unix timestamp indicating the Pull Request creation time.
OpenedBy This property is required. string
GitHub login of the user who opened the Pull Request.
State This property is required. string
If set, filters Pull Requests by state. Can be "open", "closed", or "all". Default: "open".
Title This property is required. string
The title of the Pull Request.
UpdatedAt This property is required. int
The timestamp of the last Pull Request update.
baseRef This property is required. String
If set, filters Pull Requests by base branch name.
baseSha This property is required. String
Head commit SHA of the Pull Request base.
body This property is required. String
Body of the Pull Request.
draft This property is required. Boolean
Indicates Whether this Pull Request is a draft.
headOwner This property is required. String
Owner of the Pull Request head repository.
headRef This property is required. String
If set, filters Pull Requests by head user or head organization and branch name in the format of "user:ref-name" or "organization:ref-name". For example: "github:new-script-format" or "octocat:test-branch".
headRepository This property is required. String
Name of the Pull Request head repository.
headSha This property is required. String
Head commit SHA of the Pull Request head.
labels This property is required. List<String>
List of label names set on the Pull Request.
maintainerCanModify This property is required. Boolean
Indicates whether the base repository maintainers can modify the Pull Request.
number This property is required. Integer
The number of the Pull Request within the repository.
openedAt This property is required. Integer
Unix timestamp indicating the Pull Request creation time.
openedBy This property is required. String
GitHub login of the user who opened the Pull Request.
state This property is required. String
If set, filters Pull Requests by state. Can be "open", "closed", or "all". Default: "open".
title This property is required. String
The title of the Pull Request.
updatedAt This property is required. Integer
The timestamp of the last Pull Request update.
baseRef This property is required. string
If set, filters Pull Requests by base branch name.
baseSha This property is required. string
Head commit SHA of the Pull Request base.
body This property is required. string
Body of the Pull Request.
draft This property is required. boolean
Indicates Whether this Pull Request is a draft.
headOwner This property is required. string
Owner of the Pull Request head repository.
headRef This property is required. string
If set, filters Pull Requests by head user or head organization and branch name in the format of "user:ref-name" or "organization:ref-name". For example: "github:new-script-format" or "octocat:test-branch".
headRepository This property is required. string
Name of the Pull Request head repository.
headSha This property is required. string
Head commit SHA of the Pull Request head.
labels This property is required. string[]
List of label names set on the Pull Request.
maintainerCanModify This property is required. boolean
Indicates whether the base repository maintainers can modify the Pull Request.
number This property is required. number
The number of the Pull Request within the repository.
openedAt This property is required. number
Unix timestamp indicating the Pull Request creation time.
openedBy This property is required. string
GitHub login of the user who opened the Pull Request.
state This property is required. string
If set, filters Pull Requests by state. Can be "open", "closed", or "all". Default: "open".
title This property is required. string
The title of the Pull Request.
updatedAt This property is required. number
The timestamp of the last Pull Request update.
base_ref This property is required. str
If set, filters Pull Requests by base branch name.
base_sha This property is required. str
Head commit SHA of the Pull Request base.
body This property is required. str
Body of the Pull Request.
draft This property is required. bool
Indicates Whether this Pull Request is a draft.
head_owner This property is required. str
Owner of the Pull Request head repository.
head_ref This property is required. str
If set, filters Pull Requests by head user or head organization and branch name in the format of "user:ref-name" or "organization:ref-name". For example: "github:new-script-format" or "octocat:test-branch".
head_repository This property is required. str
Name of the Pull Request head repository.
head_sha This property is required. str
Head commit SHA of the Pull Request head.
labels This property is required. Sequence[str]
List of label names set on the Pull Request.
maintainer_can_modify This property is required. bool
Indicates whether the base repository maintainers can modify the Pull Request.
number This property is required. int
The number of the Pull Request within the repository.
opened_at This property is required. int
Unix timestamp indicating the Pull Request creation time.
opened_by This property is required. str
GitHub login of the user who opened the Pull Request.
state This property is required. str
If set, filters Pull Requests by state. Can be "open", "closed", or "all". Default: "open".
title This property is required. str
The title of the Pull Request.
updated_at This property is required. int
The timestamp of the last Pull Request update.
baseRef This property is required. String
If set, filters Pull Requests by base branch name.
baseSha This property is required. String
Head commit SHA of the Pull Request base.
body This property is required. String
Body of the Pull Request.
draft This property is required. Boolean
Indicates Whether this Pull Request is a draft.
headOwner This property is required. String
Owner of the Pull Request head repository.
headRef This property is required. String
If set, filters Pull Requests by head user or head organization and branch name in the format of "user:ref-name" or "organization:ref-name". For example: "github:new-script-format" or "octocat:test-branch".
headRepository This property is required. String
Name of the Pull Request head repository.
headSha This property is required. String
Head commit SHA of the Pull Request head.
labels This property is required. List<String>
List of label names set on the Pull Request.
maintainerCanModify This property is required. Boolean
Indicates whether the base repository maintainers can modify the Pull Request.
number This property is required. Number
The number of the Pull Request within the repository.
openedAt This property is required. Number
Unix timestamp indicating the Pull Request creation time.
openedBy This property is required. String
GitHub login of the user who opened the Pull Request.
state This property is required. String
If set, filters Pull Requests by state. Can be "open", "closed", or "all". Default: "open".
title This property is required. String
The title of the Pull Request.
updatedAt This property is required. Number
The timestamp of the last Pull Request update.

Package Details

Repository
GitHub pulumi/pulumi-github
License
Apache-2.0
Notes
This Pulumi package is based on the github Terraform Provider.