Get a repository ruleset
Get a ruleset for a repository.
Note: To prevent leaking sensitive information, the bypass_actors property is only returned if the user
making the API request has write access to the ruleset.
Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ”The account owner of the repository. The name is not case sensitive.
The name of the repository without the .git extension. The name is not case sensitive.
The ID of the ruleset.
Query Parameters
Section titled “ Query Parameters ”Include rulesets configured at higher levels that apply to this repository
Responses
Section titled “ Responses ”Response
A set of rules to apply when specified conditions are met.
object
The ID of the ruleset
The name of the ruleset
The target of the ruleset
The type of the source of the ruleset
The name of the source
The enforcement level of the ruleset. evaluate allows admins to test rules before enforcing them. Admins can view insights on the Rule Insights page (evaluate is only available with GitHub Enterprise).
The actors that can bypass the rules in this ruleset
An actor that can bypass rules in a ruleset
object
The ID of the actor that can bypass a ruleset. Required for Integration, RepositoryRole, Team, and User actor types. If actor_type is OrganizationAdmin, actor_id is ignored. If actor_type is DeployKey, this should be null. OrganizationAdmin is not applicable for personal repositories.
The type of actor that can bypass a ruleset.
When the specified actor can bypass the ruleset. pull_request means that an actor can only bypass rules on pull requests. pull_request is not applicable for the DeployKey actor type. Also, pull_request is only applicable to branch rulesets. When bypass_mode is exempt, rules will not be run for that actor and a bypass audit entry will not be created.
The bypass type of the user making the API request for this ruleset. This field is only returned when querying the repository-level endpoint.
object
object
The URL of the ruleset
object
The html URL of the ruleset
Parameters for a repository ruleset ref name condition
object
object
Array of ref names or patterns to include. One of these patterns must match for the condition to pass. Also accepts ~DEFAULT_BRANCH to include the default branch or ~ALL to include all branches.
Array of ref names or patterns to exclude. The condition will not pass if any of these patterns match.
Conditions to target repositories by name and refs by name
object
object
Array of ref names or patterns to include. One of these patterns must match for the condition to pass. Also accepts ~DEFAULT_BRANCH to include the default branch or ~ALL to include all branches.
Array of ref names or patterns to exclude. The condition will not pass if any of these patterns match.
object
Array of repository names or patterns to include. One of these patterns must match for the condition to pass. Also accepts ~ALL to include all repositories.
Array of repository names or patterns to exclude. The condition will not pass if any of these patterns match.
Whether renaming of target repositories is prevented.
Conditions to target repositories by id and refs by name
object
object
Array of ref names or patterns to include. One of these patterns must match for the condition to pass. Also accepts ~DEFAULT_BRANCH to include the default branch or ~ALL to include all branches.
Array of ref names or patterns to exclude. The condition will not pass if any of these patterns match.
object
The repository IDs that the ruleset applies to. One of these IDs must match for the condition to pass.
Conditions to target repositories by property and refs by name
object
object
Array of ref names or patterns to include. One of these patterns must match for the condition to pass. Also accepts ~DEFAULT_BRANCH to include the default branch or ~ALL to include all branches.
Array of ref names or patterns to exclude. The condition will not pass if any of these patterns match.
object
The repository properties and values to include. All of these properties must match for the condition to pass.
Parameters for a targeting a repository property
object
The name of the repository property to target
The values to match for the repository property
The source of the repository property. Defaults to ‘custom’ if not specified.
The repository properties and values to exclude. The condition will not pass if any of these properties match.
Parameters for a targeting a repository property
object
The name of the repository property to target
The values to match for the repository property
The source of the repository property. Defaults to ‘custom’ if not specified.
- creation
- update
- deletion
- required_linear_history
- merge_queue
- required_deployments
- required_signatures
- pull_request
- required_status_checks
- non_fast_forward
- commit_message_pattern
- commit_author_email_pattern
- committer_email_pattern
- branch_name_pattern
- tag_name_pattern
- workflows
- code_scanning
- copilot_code_review
- license_compliance_scanning
- file_path_restriction
- max_file_path_length
- file_extension_restriction
- max_file_size
Only allow users with bypass permission to create matching refs.
object
Only allow users with bypass permission to update matching refs.
object
object
Branch can pull changes from its upstream repository
Only allow users with bypass permissions to delete matching refs.
object
Prevent merge commits from being pushed to matching refs.
object
Merges must be performed via a merge queue.
object
object
Maximum time for a required status check to report a conclusion. After this much time has elapsed, checks that have not reported a conclusion will be assumed to have failed
When set to ALLGREEN, the merge commit created by merge queue for each PR in the group must pass all required checks to merge. When set to HEADGREEN, only the commit at the head of the merge group, i.e. the commit containing changes from all of the PRs in the group, must pass its required checks to merge.
Limit the number of queued pull requests requesting checks and workflow runs at the same time.
The maximum number of PRs that will be merged together in a group.
Method to use when merging changes from queued pull requests.
The minimum number of PRs that will be merged together in a group.
The time merge queue should wait after the first PR is added to the queue for the minimum group size to be met. After this time has elapsed, the minimum group size will be ignored and a smaller group will be merged.
Choose which environments must be successfully deployed to before refs can be pushed into a ref that matches this rule.
object
object
The environments that must be successfully deployed to before branches can be merged.
Commits pushed to matching refs must have verified signatures.
object
Require all commits be made to a non-target branch and submitted via a pull request before they can be merged.
object
object
Array of allowed merge methods. Allowed values include merge, squash, and rebase. At least one option must be enabled.
New, reviewable commits pushed will dismiss previous pull request review approvals.
Specify people, teams, or apps allowed to dismiss pull request reviews.
object
Specify people, teams, or apps allowed to dismiss pull request reviews.
An actor allowed to dismiss pull request reviews
object
ID of the actor that can dismiss reviews.
The type of the actor
Whether to restrict review dismissal to specific actors.
Require an approving review in pull requests that modify files that have a designated code owner.
Whether the most recent reviewable push must be approved by someone other than the person who pushed it.
The number of approving reviews that are required before a pull request can be merged.
All conversations on code must be resolved before a pull request can be merged.
[!NOTE]
required_reviewersis in beta and subject to change.
A collection of reviewers and associated file patterns. Each reviewer has a list of file patterns which determine the files that reviewer is required to review.
A reviewing team, and file patterns describing which files they must approve changes to.
object
Array of file patterns. Pull requests which change matching files must be approved by the specified team. File patterns use fnmatch syntax.
Minimum number of approvals required from the specified team. If set to zero, the team will be added to the pull request but approval is optional.
A required reviewing team
object
ID of the reviewer which must review changes to matching files.
The type of the reviewer
Choose which status checks must pass before the ref is updated. When enabled, commits must first be pushed to another ref where the checks pass.
object
object
Allow repositories and branches to be created if a check would otherwise prohibit it.
Status checks that are required.
Required status check
object
The status check context name that must be present on the commit.
The optional integration ID that this status check must originate from.
Whether pull requests targeting a matching branch must be tested with the latest code. This setting will not take effect unless at least one status check is enabled.
Prevent users with push access from force pushing to refs.
object
Parameters to be used for the commit_message_pattern rule
object
object
How this rule appears when configuring it.
If true, the rule will fail if the pattern matches.
The operator to use for matching.
The pattern to match with.
Parameters to be used for the commit_author_email_pattern rule
object
object
How this rule appears when configuring it.
If true, the rule will fail if the pattern matches.
The operator to use for matching.
The pattern to match with.
Parameters to be used for the committer_email_pattern rule
object
object
How this rule appears when configuring it.
If true, the rule will fail if the pattern matches.
The operator to use for matching.
The pattern to match with.
Parameters to be used for the branch_name_pattern rule
object
object
How this rule appears when configuring it.
If true, the rule will fail if the pattern matches.
The operator to use for matching.
The pattern to match with.
Parameters to be used for the tag_name_pattern rule
object
object
How this rule appears when configuring it.
If true, the rule will fail if the pattern matches.
The operator to use for matching.
The pattern to match with.
Require all changes made to a targeted branch to pass the specified workflows before they can be merged.
object
object
Allow repositories and branches to be created if a check would otherwise prohibit it.
Workflows that must pass for this rule to pass.
A workflow that must run for this rule to pass
object
The path to the workflow file
The ref (branch or tag) of the workflow file to use
The ID of the repository where the workflow is defined
The commit SHA of the workflow file to use
Choose which tools must provide code scanning results before the reference is updated. When configured, code scanning must be enabled and have results for both the commit and the reference being updated.
object
object
Tools that must provide code scanning results for this rule to pass.
A tool that must provide code scanning results for this rule to pass.
object
The severity level at which code scanning results that raise alerts block a reference update. For more information on alert severity levels, see “About code scanning alerts.”
The severity level at which code scanning results that raise security alerts block a reference update. For more information on security severity levels, see “About code scanning alerts.”
The name of a code scanning tool
Request Copilot code review for new pull requests automatically if the author has access to Copilot code review and their premium requests quota has not reached the limit.
object
object
Copilot automatically reviews draft pull requests before they are marked as ready for review.
Copilot automatically reviews each new push to the pull request.
Enforce any added or changed dependencies to comply with the organization’s license policy.
object
Prevent commits that include changes in specified file and folder paths from being pushed to the commit graph. This includes absolute paths that contain file names.
object
object
The file paths that are restricted from being pushed to the commit graph.
Prevent commits that include file paths that exceed the specified character limit from being pushed to the commit graph.
object
object
The maximum amount of characters allowed in file paths.
Prevent commits that include files with specified file extensions from being pushed to the commit graph.
object
object
The file extensions that are restricted from being pushed to the commit graph.
Prevent commits with individual files that exceed the specified limit from being pushed to the commit graph.
object
object
The maximum file size allowed in megabytes. This limit does not apply to Git Large File Storage (Git LFS).
Examples
{ "id": 42, "name": "super cool ruleset", "target": "branch", "source_type": "Repository", "source": "monalisa/my-repo", "enforcement": "active", "bypass_actors": [ { "actor_id": 234, "actor_type": "Team", "bypass_mode": "always" } ], "conditions": { "ref_name": { "include": [ "refs/heads/main", "refs/heads/master" ], "exclude": [ "refs/heads/dev*" ] } }, "rules": [ { "type": "commit_author_email_pattern", "parameters": { "operator": "contains", "pattern": "github" } } ], "node_id": "RRS_lACkVXNlcgQB", "_links": { "self": { "href": "https://api.github.com/repos/monalisa/my-repo/rulesets/42" }, "html": { "href": "https://github.com/monalisa/my-repo/rules/42" } }, "created_at": "2023-07-15T08:43:03Z", "updated_at": "2023-08-23T16:29:47Z"}Resource not found
Basic Error
object
Example generated
{ "message": "example", "documentation_url": "example", "url": "example", "status": "example"}Internal Error
Basic Error
object
Example generated
{ "message": "example", "documentation_url": "example", "url": "example", "status": "example"}