The github_repository_environments
fix block in the grept
tool is used to manage the environments of a GitHub repository. This block can be used to ensure certain environments are present with specific configurations in a GitHub repository.
rule_ids
: The ID list of the rules this fix is associated with. Any rule check failure would trigger this fix.owner
: The owner of the GitHub repository.repo_name
: The name of the GitHub repository.environment
: A list of environments that must be present in the GitHub repository. Each environment is an object with the following attributes:name
: The name of the environment.can_admins_bypass
: Whether admins can bypass the required reviewers. Defaults totrue
.prevent_self_review
: Whether to prevent the creator of a deployment from approving their own deployment. Defaults tofalse
.wait_timer
: (optional) The amount of time (in minutes) to wait before auto-merging a deployment. Must be between 0 and 43200.reviewer
: A list of reviewers for the environment. Each reviewer is an object with the following attributes:team_id
: (optional) The ID of the team reviewer.user_id
: (optional) The ID of the user reviewer.
deployment_branch_policy
: The branch policy for deployments. It is an object with the following attributes:protected_branches
: Whether only branches with branch protection rules can deploy to this environment. Ifprotected_branches
istrue
,custom_branch_policies
must befalse
; ifprotected_branches
isfalse
,custom_branch_policies
must betrue
.custom_branch_policies
: Whether only branches that match the specified name patterns can deploy to this environment. Ifcustom_branch_policies
istrue
,protected_branches
must befalse
; ifcustom_branch_policies
isfalse
,protected_branches
must betrue
.
The github_repository_environments
fix block does not export any attributes.
Here's an example of how to use the github_repository_environments
fix block in your configuration file:
fix "github_repository_environments" "example" {
rule_ids = ["example_rule"]
owner = "owner_name"
repo_name = "repo_name"
environment {
name = "environment1"
can_admins_bypass = true
prevent_self_review = false
wait_timer = 10
reviewer {
team_id = 123456
}
reviewer {
user_id = 654321
}
deployment_branch_policy {
protected_branches = true
custom_branch_policies = false
}
}
}