Skip to content

Commit 5ea0367

Browse files
fix(terraform): drop restrict_pushes, unsupported on personal repos
GitHub rejects named push restrictions on non-organization repos. Dropping it doesn't weaken anything: required_pull_request_reviews already blocks direct pushes for everyone without bypass rights, and enforce_admins=false is what limits that bypass to admins.
1 parent 1d5e7cc commit 5ea0367

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

terraform/github-repository/main.tf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,15 @@ resource "github_repository" "this" {
6161
# import. Solo-maintainer defaults: a pull request and passing CI are
6262
# required, but there's no minimum approval count, since GitHub can't let
6363
# you approve your own PR. Admins aren't blanket-enforced, so you can bypass
64-
# in a genuine emergency. Nobody — not a collaborator with push access, not
65-
# a bot — can push directly to main; only repository admins retain that
66-
# ability by default.
64+
# in a genuine emergency.
65+
#
66+
# No `restrict_pushes` block: GitHub only supports named user/team push
67+
# restrictions on organization-owned repositories ("Only organization
68+
# repositories can have users and team restrictions"), and this module
69+
# targets personal repos. It's not needed to get the same outcome anyway —
70+
# `required_pull_request_reviews` already blocks direct pushes from anyone
71+
# without bypass rights, and `enforce_admins = false` is what grants that
72+
# bypass to admins only.
6773
resource "github_branch_protection" "main" {
6874
repository_id = github_repository.this.node_id
6975
pattern = "main"
@@ -77,10 +83,6 @@ resource "github_branch_protection" "main" {
7783
required_approving_review_count = 0
7884
}
7985

80-
restrict_pushes {
81-
push_allowances = []
82-
}
83-
8486
enforce_admins = false
8587
allows_deletions = false
8688
allows_force_pushes = false

0 commit comments

Comments
 (0)