Skip to content

Commit 122a98b

Browse files
committed
Merge branch 'main' into v6
2 parents 30e6569 + dbda378 commit 122a98b

4 files changed

+30
-8
lines changed

github/resource_github_repository_environment.go

+12
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ func resourceGithubRepositoryEnvironment() *schema.Resource {
3939
Default: true,
4040
Description: "Can Admins bypass deployment protections",
4141
},
42+
"prevent_self_review": {
43+
Type: schema.TypeBool,
44+
Optional: true,
45+
Default: false,
46+
Description: "Prevent users from approving workflows runs that they triggered.",
47+
},
4248
"wait_timer": {
4349
Type: schema.TypeInt,
4450
Optional: true,
@@ -174,6 +180,10 @@ func resourceGithubRepositoryEnvironmentRead(d *schema.ResourceData, meta interf
174180
}); err != nil {
175181
return err
176182
}
183+
184+
if err = d.Set("prevent_self_review", pr.PreventSelfReview); err != nil {
185+
return err
186+
}
177187
}
178188
}
179189

@@ -239,6 +249,8 @@ func createUpdateEnvironmentData(d *schema.ResourceData, meta interface{}) githu
239249

240250
data.CanAdminsBypass = github.Bool(d.Get("can_admins_bypass").(bool))
241251

252+
data.PreventSelfReview = github.Bool(d.Get("prevent_self_review").(bool))
253+
242254
if v, ok := d.GetOk("reviewers"); ok {
243255
envReviewers := make([]*github.EnvReviewers, 0)
244256

github/resource_github_repository_environment_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func TestAccGithubRepositoryEnvironment(t *testing.T) {
3030
environment = "environment / test"
3131
can_admins_bypass = false
3232
wait_timer = 10000
33+
prevent_self_review = true
3334
reviewers {
3435
users = [data.github_user.current.id]
3536
}
@@ -44,6 +45,7 @@ func TestAccGithubRepositoryEnvironment(t *testing.T) {
4445
check := resource.ComposeAggregateTestCheckFunc(
4546
resource.TestCheckResourceAttr("github_repository_environment.test", "environment", "environment / test"),
4647
resource.TestCheckResourceAttr("github_repository_environment.test", "can_admins_bypass", "false"),
48+
resource.TestCheckResourceAttr("github_repository_environment.test", "prevent_self_review", "true"),
4749
resource.TestCheckResourceAttr("github_repository_environment.test", "wait_timer", "10000"),
4850
)
4951

website/docs/r/repository_deploy_key.html.markdown

+8-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ Further documentation on GitHub repository deploy keys:
2121
## Example Usage
2222

2323
```hcl
24-
# Add a deploy key
24+
# Generate an ssh key using provider "hashicorp/tls"
25+
resource "tls_private_key" "example_repository_deploy_key" {
26+
algorithm = "ED25519"
27+
}
28+
29+
# Add the ssh key as a deploy key
2530
resource "github_repository_deploy_key" "example_repository_deploy_key" {
2631
title = "Repository test key"
2732
repository = "test-repo"
28-
key = "ssh-rsa AAA..."
29-
read_only = "false"
33+
key = tls_private_key.example_repository_deploy_key.public_key_openssh
34+
read_only = true
3035
}
3136
```
3237

website/docs/r/repository_environment.html.markdown

+8-5
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@ data "github_user" "current" {
1717
}
1818
1919
resource "github_repository" "example" {
20-
name = "A Repository Project"
21-
description = "My awesome codebase"
20+
name = "A Repository Project"
21+
description = "My awesome codebase"
2222
}
2323
2424
resource "github_repository_environment" "example" {
25-
environment = "example"
26-
repository = github_repository.example.name
25+
environment = "example"
26+
repository = github_repository.example.name
27+
prevent_self_review = true
2728
reviewers {
2829
users = [data.github_user.current.id]
2930
}
3031
deployment_branch_policy {
31-
protected_branches = true
32+
protected_branches = true
3233
custom_branch_policies = false
3334
}
3435
}
@@ -46,6 +47,8 @@ The following arguments are supported:
4647

4748
* `can_admins_bypass` - (Optional) Can repository admins bypass the environment protections. Defaults to `true`.
4849

50+
* `prevent_self_review` - (Optional) Whether or not a user who created the job is prevented from approving their own job. Defaults to `false`.
51+
4952
### Reviewers
5053

5154
The `reviewers` block supports the following:

0 commit comments

Comments
 (0)