Skip to content

Commit bc22f7a

Browse files
committed
Updated ruleset docs
Signed-off-by: Timo Sand <[email protected]>
1 parent 7a06b31 commit bc22f7a

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

website/docs/r/organization_ruleset.html.markdown

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,23 @@ resource "github_organization_ruleset" "example" {
6565
}
6666
}
6767
68-
# Example with push ruleset
68+
# Example with push ruleset
69+
# Note: Push targets must NOT have ref_name in conditions, only repository_name or repository_id
6970
resource "github_organization_ruleset" "example_push" {
7071
name = "example_push"
7172
target = "push"
7273
enforcement = "active"
7374
7475
conditions {
75-
ref_name {
76-
include = ["~ALL"]
77-
exclude = []
78-
}
7976
repository_name {
80-
include = ["~ALL"]
77+
include = ["~ALL"]
8178
exclude = []
8279
}
8380
}
8481
8582
rules {
83+
# Push targets only support these rules:
84+
# file_path_restriction, max_file_size, max_file_path_length, file_extension_restriction
8685
file_path_restriction {
8786
restricted_file_paths = [".github/workflows/*", "*.env"]
8887
}
@@ -114,12 +113,14 @@ resource "github_organization_ruleset" "example_push" {
114113

115114
* `bypass_actors` - (Optional) (Block List) The actors that can bypass the rules in this ruleset. (see [below for nested schema](#bypass_actors))
116115

117-
* `conditions` - (Optional) (Block List, Max: 1) Parameters for an organization ruleset condition. `ref_name` is required alongside one of `repository_name` or `repository_id`. (see [below for nested schema](#conditions))
116+
* `conditions` - (Optional) (Block List, Max: 1) Parameters for an organization ruleset condition. For `branch` and `tag` targets, `ref_name` is required alongside one of `repository_name` or `repository_id`. For `push` targets, `ref_name` must NOT be set - only `repository_name` or `repository_id` should be used. (see [below for nested schema](#conditions))
118117

119118
#### Rules ####
120119

121120
The `rules` block supports the following:
122121

122+
~> **Note:** Rules are target-specific. `branch` and `tag` targets support rules like `creation`, `deletion`, `pull_request`, `required_status_checks`, etc. `push` targets only support `file_path_restriction`, `max_file_size`, `max_file_path_length`, and `file_extension_restriction`. Using the wrong rules for a target will result in a validation error.
123+
123124
* `branch_name_pattern` - (Optional) (Block List, Max: 1) Parameters to be used for the branch_name_pattern rule. This rule only applies to repositories within an enterprise, it cannot be applied to repositories owned by individuals or regular organizations. Conflicts with `tag_name_pattern` as it only applies to rulesets with target `branch`. (see [below for nested schema](#rules.branch_name_pattern))
124125

125126
* `commit_author_email_pattern` - (Optional) (Block List, Max: 1) Parameters to be used for the commit_author_email_pattern rule. This rule only applies to repositories within an enterprise, it cannot be applied to repositories owned by individuals or regular organizations. (see [below for nested schema](#rules.commit_author_email_pattern))
@@ -296,12 +297,14 @@ The `rules` block supports the following:
296297

297298
#### conditions ####
298299

299-
* `ref_name` - (Required) (Block List, Min: 1, Max: 1) (see [below for nested schema](#conditions.ref_name))
300+
* `ref_name` - (Optional) (Block List, Max: 1) Required for `branch` and `tag` targets. Must NOT be set for `push` targets. (see [below for nested schema](#conditions.ref_name))
300301
* `repository_id` (Optional) (List of Number) The repository IDs that the ruleset applies to. One of these IDs must match for the condition to pass. Conflicts with `repository_name`.
301302
* `repository_name` (Optional) (Block List, Max: 1) Conflicts with `repository_id`. (see [below for nested schema](#conditions.repository_name))
302303

303304
One of `repository_id` and `repository_name` must be set for the rule to target any repositories.
304305

306+
~> **Note:** For `push` targets, do not include `ref_name` in conditions. Push rulesets operate on file content, not on refs.
307+
305308
#### conditions.ref_name ####
306309

307310
* `exclude` - (Required) (List of String) Array of ref names or patterns to exclude. The condition will not pass if any of these patterns match.

website/docs/r/repository_ruleset.html.markdown

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,16 @@ resource "github_repository_ruleset" "example_push" {
9898

9999
* `bypass_actors` - (Optional) (Block List) The actors that can bypass the rules in this ruleset. (see [below for nested schema](#bypass_actors))
100100

101-
* `conditions` - (Optional) (Block List, Max: 1) Parameters for a repository ruleset ref name condition. (see [below for nested schema](#conditions))
101+
* `conditions` - (Optional) (Block List, Max: 1) Parameters for a repository ruleset condition. For `branch` and `tag` targets, `ref_name` is required. For `push` targets, `ref_name` must NOT be set - conditions are optional for push targets. (see [below for nested schema](#conditions))
102102

103103
* `repository` - (Required) (String) Name of the repository to apply ruleset to.
104104

105105
#### Rules ####
106106

107107
The `rules` block supports the following:
108108

109+
~> **Note:** Rules are target-specific. `branch` and `tag` targets support rules like `creation`, `deletion`, `pull_request`, `required_status_checks`, etc. `push` targets only support `file_path_restriction`, `max_file_size`, `max_file_path_length`, and `file_extension_restriction`. Using the wrong rules for a target will result in a validation error.
110+
109111
* `branch_name_pattern` - (Optional) (Block List, Max: 1) Parameters to be used for the branch_name_pattern rule. This rule only applies to repositories within an enterprise, it cannot be applied to repositories owned by individuals or regular organizations. Conflicts with `tag_name_pattern` as it only applied to rulesets with target `branch`. (see [below for nested schema](#rulesbranch_name_pattern))
110112

111113
* `commit_author_email_pattern` - (Optional) (Block List, Max: 1) Parameters to be used for the commit_author_email_pattern rule. This rule only applies to repositories within an enterprise, it cannot be applied to repositories owned by individuals or regular organizations. (see [below for nested schema](#rulescommit_author_email_pattern))
@@ -136,9 +138,9 @@ The `rules` block supports the following:
136138

137139
* `required_code_scanning` - (Optional) (Block List, Max: 1) Define 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. Multiple code scanning tools can be specified. (see [below for nested schema](#rulesrequired_code_scanning))
138140

139-
* `file_path_restriction` - (Optional) (Block List, Max 1) Parameters to be used for the file_path_restriction rule. When enabled restricts access to files within the repository. (See [below for nested schema](#rules.file_path_restriction))
141+
* `file_path_restriction` - (Optional) (Block List, Max 1) Parameters to be used for the file_path_restriction rule. This rule only applies to rulesets with target `push`. (See [below for nested schema](#rules.file_path_restriction))
140142

141-
* `max_file_size` - (Optional) (Block List, Max 1) Parameters to be used for the max_file_size rule. When enabled restricts the maximum size of a file that can be pushed to the repository. (See [below for nested schema](#rules.max_file_size))
143+
* `max_file_size` - (Optional) (Block List, Max 1) Parameters to be used for the max_file_size rule. This rule only applies to rulesets with target `push`. (See [below for nested schema](#rules.max_file_size))
142144

143145
* `max_file_path_length` - (Optional) (Block List, Max: 1) Prevent commits that include file paths that exceed a specified character limit from being pushed to the commit graph. This rule only applies to rulesets with target `push`. (see [below for nested schema](#rules.max_file_path_length))
144146

@@ -289,7 +291,9 @@ The `rules` block supports the following:
289291

290292
#### conditions ####
291293

292-
* `ref_name` - (Required) (Block List, Min: 1, Max: 1) (see [below for nested schema](#conditions.ref_name))
294+
* `ref_name` - (Optional) (Block List, Max: 1) Required for `branch` and `tag` targets. Must NOT be set for `push` targets. (see [below for nested schema](#conditions.ref_name))
295+
296+
~> **Note:** For `push` targets, do not include `ref_name` in conditions. Push rulesets operate on file content, not on refs. The `conditions` block is optional for push targets.
293297

294298
#### conditions.ref_name ####
295299

0 commit comments

Comments
 (0)