Skip to main content
설명서에 자주 업데이트를 게시하며 이 페이지의 번역이 계속 진행 중일 수 있습니다. 최신 정보는 영어 설명서를 참조하세요.
이제 REST API의 버전이 지정됩니다. 자세한 내용은 "API 버전 관리 정보"를 참조하세요.

Rules

Use the rulesets API to manage rulesets for repositories. Organization rulesets control how people can interact with selected branches and tags in repositories in an organization.

Note: Rulesets are in public beta and subject to change.

Get all organization repository rulesets

에서 작동 GitHub Apps

Get all the repository rulesets for an organization.

"Get all organization repository rulesets"에 대한 매개 변수

헤더
이름, 형식, Description
accept string

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, 형식, Description
org string 필수

The organization name. The name is not case sensitive.

"Get all organization repository rulesets"에 대한 HTTP 응답 상태 코드

상태 코드Description
200

OK

404

Resource not found

500

Internal Error

"Get all organization repository rulesets"에 대한 코드 샘플

get/orgs/{org}/rulesets
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/rulesets

Response

Status: 200
[ { "id": 21, "name": "super cool ruleset", "source_type": "Organization", "source": "my-org", "enforcement": "enabled" }, { "id": 432, "name": "Another ruleset", "source_type": "Organization", "source": "my-org", "enforcement": "enabled" } ]

Create an organization repository ruleset

에서 작동 GitHub Apps

Create a repository ruleset for an organization.

"Create an organization repository ruleset"에 대한 매개 변수

헤더
이름, 형식, Description
accept string

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, 형식, Description
org string 필수

The organization name. The name is not case sensitive.

본문 매개 변수
이름, 형식, Description
name string 필수

The name of the ruleset.

target string

The target of the ruleset.

다음 중 하나일 수 있습니다.: branch, tag

enforcement string 필수

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).

다음 중 하나일 수 있습니다.: disabled, active, evaluate

bypass_actors array of objects

The actors that can bypass the rules in this ruleset

이름, 형식, Description
actor_id integer

The ID of the actor that can bypass a ruleset

actor_type string

The type of actor that can bypass a ruleset

다음 중 하나일 수 있습니다.: Team, Integration

conditions object

Conditions for a organization ruleset

rules array of objects

An array of rules within the ruleset.

이름, 형식, Description
creation object 필수

Parameters to be used for the creation rule

이름, 형식, Description
type string 필수

: creation

update object 필수

Parameters to be used for the update rule

이름, 형식, Description
type string 필수

: update

parameters object
이름, 형식, Description
update_allows_fetch_and_merge boolean 필수

Branch can pull changes from its upstream repository

deletion object 필수

Parameters to be used for the deletion rule

이름, 형식, Description
type string 필수

: deletion

required_linear_history object 필수

Parameters to be used for the required_linear_history rule

이름, 형식, Description
type string 필수

: required_linear_history

required_deployments object 필수

Parameters to be used for the required_deployments rule

이름, 형식, Description
type string 필수

: required_deployments

parameters object
이름, 형식, Description
required_deployment_environments array of strings 필수

The environments that must be successfully deployed to before branches can be merged.

required_signatures object 필수

Parameters to be used for the required_signatures rule

이름, 형식, Description
type string 필수

: required_signatures

pull_request object 필수

Parameters to be used for the pull_request rule

이름, 형식, Description
type string 필수

: pull_request

parameters object
이름, 형식, Description
dismiss_stale_reviews_on_push boolean 필수

New, reviewable commits pushed will dismiss previous pull request review approvals.

require_code_owner_review boolean 필수

Require an approving review in pull requests that modify files that have a designated code owner.

require_last_push_approval boolean 필수

Whether the most recent reviewable push must be approved by someone other than the person who pushed it.

required_approving_review_count integer 필수

The number of approving reviews that are required before a pull request can be merged.

required_review_thread_resolution boolean 필수

All conversations on code must be resolved before a pull request can be merged.

required_status_checks object 필수

Parameters to be used for the required_status_checks rule

이름, 형식, Description
type string 필수

: required_status_checks

parameters object
이름, 형식, Description
required_status_checks array of objects 필수

Status checks that are required.

이름, 형식, Description
context string 필수

The status check context name that must be present on the commit.

integration_id integer

The optional integration ID that this status check must originate from.

strict_required_status_checks_policy boolean 필수

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.

non_fast_forward object 필수

Parameters to be used for the non_fast_forward rule

이름, 형식, Description
type string 필수

: non_fast_forward

commit_message_pattern object 필수

Parameters to be used for the commit_message_pattern rule

이름, 형식, Description
type string 필수

: commit_message_pattern

parameters object
이름, 형식, Description
name string

How this rule will appear to users.

negate boolean

If true, the rule will fail if the pattern matches.

operator string 필수

The operator to use for matching.

다음 중 하나일 수 있습니다.: starts_with, ends_with, contains, regex

pattern string 필수

The pattern to match with.

commit_author_email_pattern object 필수

Parameters to be used for the commit_author_email_pattern rule

이름, 형식, Description
type string 필수

: commit_author_email_pattern

parameters object
이름, 형식, Description
name string

How this rule will appear to users.

negate boolean

If true, the rule will fail if the pattern matches.

operator string 필수

The operator to use for matching.

다음 중 하나일 수 있습니다.: starts_with, ends_with, contains, regex

pattern string 필수

The pattern to match with.

committer_email_pattern object 필수

Parameters to be used for the committer_email_pattern rule

이름, 형식, Description
type string 필수

: committer_email_pattern

parameters object
이름, 형식, Description
name string

How this rule will appear to users.

negate boolean

If true, the rule will fail if the pattern matches.

operator string 필수

The operator to use for matching.

다음 중 하나일 수 있습니다.: starts_with, ends_with, contains, regex

pattern string 필수

The pattern to match with.

branch_name_pattern object 필수

Parameters to be used for the branch_name_pattern rule

이름, 형식, Description
type string 필수

: branch_name_pattern

parameters object
이름, 형식, Description
name string

How this rule will appear to users.

negate boolean

If true, the rule will fail if the pattern matches.

operator string 필수

The operator to use for matching.

다음 중 하나일 수 있습니다.: starts_with, ends_with, contains, regex

pattern string 필수

The pattern to match with.

tag_name_pattern object 필수

Parameters to be used for the tag_name_pattern rule

이름, 형식, Description
type string 필수

: tag_name_pattern

parameters object
이름, 형식, Description
name string

How this rule will appear to users.

negate boolean

If true, the rule will fail if the pattern matches.

operator string 필수

The operator to use for matching.

다음 중 하나일 수 있습니다.: starts_with, ends_with, contains, regex

pattern string 필수

The pattern to match with.

"Create an organization repository ruleset"에 대한 HTTP 응답 상태 코드

상태 코드Description
201

Created

404

Resource not found

500

Internal Error

"Create an organization repository ruleset"에 대한 코드 샘플

post/orgs/{org}/rulesets
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/rulesets \ -d '{"name":"super cool ruleset","target":"branch","enforcement":"active","bypass_actors":[{"actor_id":234,"actor_type":"Team"}],"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"}}]}'

Response

Status: 201
{ "id": 21, "name": "super cool ruleset", "target": "branch", "source_type": "Organization", "source": "my-org", "enforcement": "active", "bypass_actors": [ { "actor_id": 234, "actor_type": "Team" } ], "conditions": { "ref_name": { "include": [ "refs/heads/main", "refs/heads/master" ], "exclude": [ "refs/heads/dev*" ] }, "repository_name": { "include": [ "important_repository", "another_important_repository" ], "exclude": [ "unimportant_repository" ], "protected": true } }, "rules": [ { "type": "commit_author_email_pattern", "parameters": { "operator": "contains", "pattern": "github" } } ] }

Get an organization repository ruleset

에서 작동 GitHub Apps

Get a repository ruleset for an organization.

"Get an organization repository ruleset"에 대한 매개 변수

헤더
이름, 형식, Description
accept string

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, 형식, Description
org string 필수

The organization name. The name is not case sensitive.

ruleset_id integer 필수

The ID of the ruleset.

"Get an organization repository ruleset"에 대한 HTTP 응답 상태 코드

상태 코드Description
200

OK

404

Resource not found

500

Internal Error

"Get an organization repository ruleset"에 대한 코드 샘플

get/orgs/{org}/rulesets/{ruleset_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/rulesets/RULESET_ID

Response

Status: 200
{ "id": 21, "name": "super cool ruleset", "target": "branch", "source_type": "Organization", "source": "my-org", "enforcement": "active", "bypass_actors": [ { "actor_id": 234, "actor_type": "Team" } ], "conditions": { "ref_name": { "include": [ "refs/heads/main", "refs/heads/master" ], "exclude": [ "refs/heads/dev*" ] }, "repository_name": { "include": [ "important_repository", "another_important_repository" ], "exclude": [ "unimportant_repository" ], "protected": true } }, "rules": [ { "type": "commit_author_email_pattern", "parameters": { "operator": "contains", "pattern": "github" } } ] }

Update an organization repository ruleset

에서 작동 GitHub Apps

Update a ruleset for an organization.

"Update an organization repository ruleset"에 대한 매개 변수

헤더
이름, 형식, Description
accept string

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, 형식, Description
org string 필수

The organization name. The name is not case sensitive.

ruleset_id integer 필수

The ID of the ruleset.

본문 매개 변수
이름, 형식, Description
name string

The name of the ruleset.

target string

The target of the ruleset.

다음 중 하나일 수 있습니다.: branch, tag

enforcement string

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).

다음 중 하나일 수 있습니다.: disabled, active, evaluate

bypass_actors array of objects

The actors that can bypass the rules in this ruleset

이름, 형식, Description
actor_id integer

The ID of the actor that can bypass a ruleset

actor_type string

The type of actor that can bypass a ruleset

다음 중 하나일 수 있습니다.: Team, Integration

conditions object

Conditions for a organization ruleset

rules array of objects

An array of rules within the ruleset.

이름, 형식, Description
creation object 필수

Parameters to be used for the creation rule

이름, 형식, Description
type string 필수

: creation

update object 필수

Parameters to be used for the update rule

이름, 형식, Description
type string 필수

: update

parameters object
이름, 형식, Description
update_allows_fetch_and_merge boolean 필수

Branch can pull changes from its upstream repository

deletion object 필수

Parameters to be used for the deletion rule

이름, 형식, Description
type string 필수

: deletion

required_linear_history object 필수

Parameters to be used for the required_linear_history rule

이름, 형식, Description
type string 필수

: required_linear_history

required_deployments object 필수

Parameters to be used for the required_deployments rule

이름, 형식, Description
type string 필수

: required_deployments

parameters object
이름, 형식, Description
required_deployment_environments array of strings 필수

The environments that must be successfully deployed to before branches can be merged.

required_signatures object 필수

Parameters to be used for the required_signatures rule

이름, 형식, Description
type string 필수

: required_signatures

pull_request object 필수

Parameters to be used for the pull_request rule

이름, 형식, Description
type string 필수

: pull_request

parameters object
이름, 형식, Description
dismiss_stale_reviews_on_push boolean 필수

New, reviewable commits pushed will dismiss previous pull request review approvals.

require_code_owner_review boolean 필수

Require an approving review in pull requests that modify files that have a designated code owner.

require_last_push_approval boolean 필수

Whether the most recent reviewable push must be approved by someone other than the person who pushed it.

required_approving_review_count integer 필수

The number of approving reviews that are required before a pull request can be merged.

required_review_thread_resolution boolean 필수

All conversations on code must be resolved before a pull request can be merged.

required_status_checks object 필수

Parameters to be used for the required_status_checks rule

이름, 형식, Description
type string 필수

: required_status_checks

parameters object
이름, 형식, Description
required_status_checks array of objects 필수

Status checks that are required.

이름, 형식, Description
context string 필수

The status check context name that must be present on the commit.

integration_id integer

The optional integration ID that this status check must originate from.

strict_required_status_checks_policy boolean 필수

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.

non_fast_forward object 필수

Parameters to be used for the non_fast_forward rule

이름, 형식, Description
type string 필수

: non_fast_forward

commit_message_pattern object 필수

Parameters to be used for the commit_message_pattern rule

이름, 형식, Description
type string 필수

: commit_message_pattern

parameters object
이름, 형식, Description
name string

How this rule will appear to users.

negate boolean

If true, the rule will fail if the pattern matches.

operator string 필수

The operator to use for matching.

다음 중 하나일 수 있습니다.: starts_with, ends_with, contains, regex

pattern string 필수

The pattern to match with.

commit_author_email_pattern object 필수

Parameters to be used for the commit_author_email_pattern rule

이름, 형식, Description
type string 필수

: commit_author_email_pattern

parameters object
이름, 형식, Description
name string

How this rule will appear to users.

negate boolean

If true, the rule will fail if the pattern matches.

operator string 필수

The operator to use for matching.

다음 중 하나일 수 있습니다.: starts_with, ends_with, contains, regex

pattern string 필수

The pattern to match with.

committer_email_pattern object 필수

Parameters to be used for the committer_email_pattern rule

이름, 형식, Description
type string 필수

: committer_email_pattern

parameters object
이름, 형식, Description
name string

How this rule will appear to users.

negate boolean

If true, the rule will fail if the pattern matches.

operator string 필수

The operator to use for matching.

다음 중 하나일 수 있습니다.: starts_with, ends_with, contains, regex

pattern string 필수

The pattern to match with.

branch_name_pattern object 필수

Parameters to be used for the branch_name_pattern rule

이름, 형식, Description
type string 필수

: branch_name_pattern

parameters object
이름, 형식, Description
name string

How this rule will appear to users.

negate boolean

If true, the rule will fail if the pattern matches.

operator string 필수

The operator to use for matching.

다음 중 하나일 수 있습니다.: starts_with, ends_with, contains, regex

pattern string 필수

The pattern to match with.

tag_name_pattern object 필수

Parameters to be used for the tag_name_pattern rule

이름, 형식, Description
type string 필수

: tag_name_pattern

parameters object
이름, 형식, Description
name string

How this rule will appear to users.

negate boolean

If true, the rule will fail if the pattern matches.

operator string 필수

The operator to use for matching.

다음 중 하나일 수 있습니다.: starts_with, ends_with, contains, regex

pattern string 필수

The pattern to match with.

"Update an organization repository ruleset"에 대한 HTTP 응답 상태 코드

상태 코드Description
200

OK

404

Resource not found

500

Internal Error

"Update an organization repository ruleset"에 대한 코드 샘플

put/orgs/{org}/rulesets/{ruleset_id}
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/rulesets/RULESET_ID \ -d '{"name":"super cool ruleset","target":"branch","enforcement":"active","bypass_actors":[{"actor_id":234,"actor_type":"Team"}],"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"}}]}'

Response

Status: 200
{ "id": 21, "name": "super cool ruleset", "target": "branch", "source_type": "Organization", "source": "my-org", "enforcement": "active", "bypass_actors": [ { "actor_id": 234, "actor_type": "Team" } ], "conditions": { "ref_name": { "include": [ "refs/heads/main", "refs/heads/master" ], "exclude": [ "refs/heads/dev*" ] }, "repository_name": { "include": [ "important_repository", "another_important_repository" ], "exclude": [ "unimportant_repository" ], "protected": true } }, "rules": [ { "type": "commit_author_email_pattern", "parameters": { "operator": "contains", "pattern": "github" } } ] }

Delete an organization repository ruleset

에서 작동 GitHub Apps

Delete a ruleset for an organization.

"Delete an organization repository ruleset"에 대한 매개 변수

헤더
이름, 형식, Description
accept string

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, 형식, Description
org string 필수

The organization name. The name is not case sensitive.

ruleset_id integer 필수

The ID of the ruleset.

"Delete an organization repository ruleset"에 대한 HTTP 응답 상태 코드

상태 코드Description
204

No Content

404

Resource not found

500

Internal Error

"Delete an organization repository ruleset"에 대한 코드 샘플

delete/orgs/{org}/rulesets/{ruleset_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/rulesets/RULESET_ID

Response

Status: 204