Skip to main content

pr_review_protection

Creates, updates, deletes, gets or lists a pr_review_protection resource.

Overview

Namepr_review_protection
TypeResource
Idgithub.repos.pr_review_protection

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
bypass_pull_request_allowancesobjectAllow specific users, teams, or apps to bypass pull request requirements.
dismiss_stale_reviewsboolean
dismissal_restrictionsobject
require_code_owner_reviewsboolean
require_last_push_approvalbooleanWhether the most recent push must be approved by someone other than the person who pushed it.
required_approving_review_countinteger
urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/branches/master/protection/dismissal_restrictions)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_pull_request_review_protectionselectowner, repo, branchProtected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.
update_pull_request_review_protectionupdateowner, repo, branchProtected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Updating pull request review enforcement requires admin or owner permissions to the repository and branch protection to be enabled.

> [!NOTE]
> Passing new arrays of users and teams replaces their previous values.
delete_pull_request_review_protectiondeleteowner, repo, branchProtected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
branchstringThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
ownerstringThe account owner of the repository. The name is not case sensitive.
repostringThe name of the repository without the .git extension. The name is not case sensitive.

SELECT examples

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

SELECT
bypass_pull_request_allowances,
dismiss_stale_reviews,
dismissal_restrictions,
require_code_owner_reviews,
require_last_push_approval,
required_approving_review_count,
url
FROM github.repos.pr_review_protection
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND branch = '{{ branch }}' -- required
;

UPDATE examples

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Updating pull request review enforcement requires admin or owner permissions to the repository and branch protection to be enabled.

> [!NOTE]
> Passing new arrays of users and teams replaces their previous values.

UPDATE github.repos.pr_review_protection
SET
dismissal_restrictions = '{{ dismissal_restrictions }}',
dismiss_stale_reviews = {{ dismiss_stale_reviews }},
require_code_owner_reviews = {{ require_code_owner_reviews }},
required_approving_review_count = {{ required_approving_review_count }},
require_last_push_approval = {{ require_last_push_approval }},
bypass_pull_request_allowances = '{{ bypass_pull_request_allowances }}'
WHERE
owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND branch = '{{ branch }}' --required
RETURNING
bypass_pull_request_allowances,
dismiss_stale_reviews,
dismissal_restrictions,
require_code_owner_reviews,
require_last_push_approval,
required_approving_review_count,
url;

DELETE examples

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

DELETE FROM github.repos.pr_review_protection
WHERE owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND branch = '{{ branch }}' --required
;