Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ Removing a repository from the YAML archives it instead of deleting it. Every re

Every repository is managed with `delete_branch_on_merge = true`, so GitHub deletes a pull request's head branch once it is merged. A deleted branch can be restored from its pull request.

### Secret Scanning

Every repository is managed with secret scanning and push protection enabled, so GitHub alerts on committed secrets and blocks pushes containing them. Non-provider patterns and validity checks are not managed.

Set it as source of truth:

```shell
Expand Down
10 changes: 10 additions & 0 deletions terraform/modules/repository/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ resource "github_repository" "this" {
delete_branch_on_merge = true
is_template = var.repository.is_template

# advanced_security omitted: setting it errors on public repositories.
security_and_analysis {
secret_scanning {
status = "enabled"
}
secret_scanning_push_protection {
status = "enabled"
}
}

# Contents
dynamic "template" {
for_each = var.repository.template == null ? [] : [var.repository.template]
Expand Down
10 changes: 10 additions & 0 deletions terraform/modules/repository/tests/repository.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ run "name_only" {
condition = github_repository.this.delete_branch_on_merge
error_message = "Repository must delete branches on merge."
}

assert {
condition = github_repository.this.security_and_analysis[0].secret_scanning[0].status == "enabled"
error_message = "Repository must enable secret scanning."
}

assert {
condition = github_repository.this.security_and_analysis[0].secret_scanning_push_protection[0].status == "enabled"
error_message = "Repository must enable secret scanning push protection."
}
}

run "name_leading_dot" {
Expand Down
Loading