Skip to content

Commit ea0f9d4

Browse files
ci(terraform): add repository rules as code (#4)
Manage GitHub repo settings and main branch protection via terraform-module-github-repository, matching webdev-bot. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent fe4fb7d commit ea0f9d4

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/terraform/repository/ @wiktoriavh
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Terraform Repository
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- terraform/repository/**
8+
9+
concurrency:
10+
group: terraform-repository-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
apply:
15+
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
working-directory: terraform/repository
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Terraform
25+
uses: hashicorp/setup-terraform@v3
26+
with:
27+
terraform_version: 1.5.0
28+
29+
- name: Terraform Init
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
run: terraform init
33+
34+
- name: Terraform Apply
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: terraform apply -auto-approve

terraform/repository/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ module "repository" {
8484
required_pull_request_reviews = {
8585
# New commits dismiss previous approvals so reviewers re-check changes.
8686
dismiss_stale_reviews = true
87+
# Require approval from CODEOWNERS when changed files match .github/CODEOWNERS.
88+
require_code_owner_reviews = true
8789
# At least one approving review from someone other than the author.
8890
required_approving_review_count = 1
8991
}

0 commit comments

Comments
 (0)