POST /repos/{owner}/{repo}/rulesets

Create a ruleset for a repository.

Servers

Path parameters

Name Type Required Description
repo String Yes

The name of the repository without the .git extension. The name is not case sensitive.

owner String Yes

The account owner of the repository. The name is not case sensitive.

Request headers

Name Type Required Description
Content-Type String Yes The media type of the request body.

Default value: "application/json"

Request body fields

Name Type Required Description
rules[] Array No

An array of rules within the ruleset.

name String Yes

The name of the ruleset.

target String No

The target of the ruleset

Possible values:

  • "branch"
  • "push"
  • "tag"

Default value: "branch"

conditions Object No

Parameters for a repository ruleset ref name condition

conditions.ref_name Object No
conditions.ref_name.include[] Array No

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.

conditions.ref_name.exclude[] Array No

Array of ref names or patterns to exclude. The condition will not pass if any of these patterns match.

bypass_actors[] Array No

The actors that can bypass the rules in this ruleset

bypass_actors[].bypass_mode String No

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.

Possible values:

  • "pull_request"
  • "always"

Default value: "always"

bypass_actors[].actor_id Integer No

The ID of the actor that can bypass a ruleset. If actor_type is OrganizationAdmin, this should be 1. If actor_type is DeployKey, this should be null. OrganizationAdmin is not applicable for personal repositories.

bypass_actors[].actor_type String Yes

The type of actor that can bypass a ruleset.

Possible values:

  • "Team"
  • "DeployKey"
  • "Integration"
  • "OrganizationAdmin"
  • "RepositoryRole"
enforcement String Yes

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

Possible values:

  • "active"
  • "disabled"
  • "evaluate"

How to start integrating

  1. Add HTTP Task to your workflow definition.
  2. Search for the API you want to integrate with and click on the name.
    • This loads the API reference documentation and prepares the Http request settings.
  3. Click Test request to test run your request to the API and see the API's response.