Skip to content

Commit

Permalink
Merge branch 'main' into v6
Browse files Browse the repository at this point in the history
  • Loading branch information
kfcampbell committed Jan 22, 2024
2 parents 30e6569 + dbda378 commit 122a98b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
12 changes: 12 additions & 0 deletions github/resource_github_repository_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ func resourceGithubRepositoryEnvironment() *schema.Resource {
Default: true,
Description: "Can Admins bypass deployment protections",
},
"prevent_self_review": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Prevent users from approving workflows runs that they triggered.",
},
"wait_timer": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -174,6 +180,10 @@ func resourceGithubRepositoryEnvironmentRead(d *schema.ResourceData, meta interf
}); err != nil {
return err
}

if err = d.Set("prevent_self_review", pr.PreventSelfReview); err != nil {
return err
}
}
}

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

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

data.PreventSelfReview = github.Bool(d.Get("prevent_self_review").(bool))

if v, ok := d.GetOk("reviewers"); ok {
envReviewers := make([]*github.EnvReviewers, 0)

Expand Down
2 changes: 2 additions & 0 deletions github/resource_github_repository_environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestAccGithubRepositoryEnvironment(t *testing.T) {
environment = "environment / test"
can_admins_bypass = false
wait_timer = 10000
prevent_self_review = true
reviewers {
users = [data.github_user.current.id]
}
Expand All @@ -44,6 +45,7 @@ func TestAccGithubRepositoryEnvironment(t *testing.T) {
check := resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("github_repository_environment.test", "environment", "environment / test"),
resource.TestCheckResourceAttr("github_repository_environment.test", "can_admins_bypass", "false"),
resource.TestCheckResourceAttr("github_repository_environment.test", "prevent_self_review", "true"),
resource.TestCheckResourceAttr("github_repository_environment.test", "wait_timer", "10000"),
)

Expand Down
11 changes: 8 additions & 3 deletions website/docs/r/repository_deploy_key.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ Further documentation on GitHub repository deploy keys:
## Example Usage

```hcl
# Add a deploy key
# Generate an ssh key using provider "hashicorp/tls"
resource "tls_private_key" "example_repository_deploy_key" {
algorithm = "ED25519"
}
# Add the ssh key as a deploy key
resource "github_repository_deploy_key" "example_repository_deploy_key" {
title = "Repository test key"
repository = "test-repo"
key = "ssh-rsa AAA..."
read_only = "false"
key = tls_private_key.example_repository_deploy_key.public_key_openssh
read_only = true
}
```

Expand Down
13 changes: 8 additions & 5 deletions website/docs/r/repository_environment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ data "github_user" "current" {
}
resource "github_repository" "example" {
name = "A Repository Project"
description = "My awesome codebase"
name = "A Repository Project"
description = "My awesome codebase"
}
resource "github_repository_environment" "example" {
environment = "example"
repository = github_repository.example.name
environment = "example"
repository = github_repository.example.name
prevent_self_review = true
reviewers {
users = [data.github_user.current.id]
}
deployment_branch_policy {
protected_branches = true
protected_branches = true
custom_branch_policies = false
}
}
Expand All @@ -46,6 +47,8 @@ The following arguments are supported:

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

* `prevent_self_review` - (Optional) Whether or not a user who created the job is prevented from approving their own job. Defaults to `false`.

### Reviewers

The `reviewers` block supports the following:
Expand Down

0 comments on commit 122a98b

Please sign in to comment.