Resource
dcloud_git_branch_protection
A branch protection rule of a repository: the branches matching branch_pattern need pull requests, approvals or status checks, refuse force pushes or deletion, or merge through a queue.
Example Usage
resource "dcloud_git_branch_protection" "main" {
repository_id = dcloud_git_repository.api.id
branch_pattern = "main"
require_pull_request = true
required_approvals = 1
require_status_checks = true
required_checks = ["CI"]
block_force_push = true
block_deletion = true
}Schema
Required
branch_pattern(String) The branch name or glob the rule covers, e.g. main or release/*. Up to 200 characters.repository_id(String) The id of the parent resource ({repoId}in the path). Changing it replaces the resource.
Optional
block_deletion(Boolean) Refuse deleting the branch (true on a new rule)block_force_push(Boolean) Refuse pushes that rewrite the branch history (true on a new rule)dismiss_stale_approvals(Boolean) A push to the pull request dismisses the approvals given before it (false on a new rule)merge_queue_build_concurrency(Number) How many queued pull requests may be building at once (5 on a new rule). From 1 to 100.merge_queue_check_timeout_minutes(Number) Minutes a queue build may wait for its checks before it fails (60 on a new rule). From 1 to 360.merge_queue_max_group_size(Number) Most pull requests landed by one fast-forward (5 on a new rule). From 1 to 100.merge_queue_method(String) How the queue merges each pull request (merge on a new rule) One of:merge,squash,rebase.merge_queue_min_group_size(Number) Fewest pull requests the queue waits for before it builds, up to the wait time (1 on a new rule). From 1 to 100.merge_queue_only_non_failing(Boolean) Land only pull requests whose own build passed; off, a failed build still lands if a later build containing it passes (true on a new rule)merge_queue_wait_minutes(Number) Minutes to wait for the minimum group size before building anyway (5 on a new rule). From 0 to 360.require_code_owner_review(Boolean) Every changed file CODEOWNERS assigns needs an approval from one of its ownersrequire_merge_queue(Boolean) The branch moves only through its merge queue; direct pushes and the merge button are refused (false on a new rule)require_pull_request(Boolean) Changes land only through a pull request; direct pushes are refused (true on a new rule)require_status_checks(Boolean) Required checks must pass before a pull request can merge (false on a new rule)required_approvals(Number) Approvals a pull request needs before it can merge (0 on a new rule). From 0 to 10.required_checks(List of String) Workflow or status names that must pass; empty means every workflow a pull request to the branch triggers
Read-Only
id(String) The resource's id.
Import
Import is supported using the following syntax:
The terraform import command can be used, for example:
terraform import dcloud_git_branch_protection.main <repository-id>/<rule-id>Generated from the provider's schema.
Related