@@ -28,7 +28,8 @@ A [Terraform] module for creating a public or private repository on [Github].
2828 - [ Collaborator Configuration] ( #collaborator-configuration )
2929 - [ Branches Configuration] ( #branches-configuration )
3030 - [ Deploy Keys Configuration] ( #deploy-keys-configuration )
31- - [ Branch Protections Configuration] ( #branch-protections-configuration )
31+ - [ Branch Protections v3 Configuration] ( #branch-protections-v3-configuration )
32+ - [ Branch Protections v4 Configuration] ( #branch-protections-v4-configuration )
3233 - [ Issue Labels Configuration] ( #issue-labels-configuration )
3334 - [ Projects Configuration] ( #projects-configuration )
3435 - [ Webhooks Configuration] ( #webhooks-configuration )
@@ -528,11 +529,11 @@ This is due to some terraform limitation and we will update the module once terr
528529
529530 Default is ` "md5(key)" ` .
530531
531- #### Branch Protections Configuration
532+ #### Branch Protections v3 Configuration
532533
533534- [ ** ` branch_protections_v3 ` ** ] ( #var-branch_protections_v3 ) : * (Optional ` list(branch_protection_v3) ` )* <a name =" var-branch_protections_v3 " ></a >
534535
535- This resource allows you to configure branch protection for repositories in your organization.
536+ This resource allows you to configure v3 branch protection for repositories in your organization.
536537 When applied, the branch will be protected from forced pushes and deletion.
537538 Additional constraints, such as required status checks or restrictions on users and teams, can also be configured.
538539
@@ -652,6 +653,135 @@ This is due to some terraform limitation and we will update the module once terr
652653
653654 Default is ` [] ` .
654655
656+ #### Branch Protections v4 Configuration
657+
658+ - [ ** ` branch_protections_v4 ` ** ] ( #var-branch_protections_v4 ) : * (Optional ` map(branch_protection_v4) ` )* <a name =" var-branch_protections_v4 " ></a >
659+
660+ This map allows you to configure v4 branch protection for repositories in your organization.
661+
662+ Each element in the map is a branch to be protected and the value the corresponding to the desired configuration for the branch.
663+
664+ When applied, the branch will be protected from forced pushes and deletion.
665+ Additional constraints, such as required status checks or restrictions on users and teams, can also be configured.
666+
667+ ** _ NOTE_ ** This will take precedence over v3 branch protections.
668+
669+ Default is ` null ` .
670+
671+ Each ` branch_protection_v4 ` object in the map accepts the following attributes:
672+
673+ - [ ** ` allows_deletions ` ** ] ( #attr-branch_protections_v4-allows_deletions ) : * (Optional ` bool ` )* <a name =" attr-branch_protections_v4-allows_deletions " ></a >
674+
675+ Setting this to true to allow the branch to be deleted.
676+
677+ Default is ` false ` .
678+
679+ - [ ** ` allows_force_pushes ` ** ] ( #attr-branch_protections_v4-allows_force_pushes ) : * (Optional ` bool ` )* <a name =" attr-branch_protections_v4-allows_force_pushes " ></a >
680+
681+ Setting this to true to allow force pushes on the branch.
682+
683+ Default is ` false ` .
684+
685+ - [ ** ` blocks_creations ` ** ] ( #attr-branch_protections_v4-blocks_creations ) : * (Optional ` bool ` )* <a name =" attr-branch_protections_v4-blocks_creations " ></a >
686+
687+ Setting this to true will block creating the branch.
688+
689+ Default is ` false ` .
690+
691+ - [ ** ` enforce_admins ` ** ] ( #attr-branch_protections_v4-enforce_admins ) : * (Optional ` bool ` )* <a name =" attr-branch_protections_v4-enforce_admins " ></a >
692+
693+ Setting this to true enforces status checks for repository administrators.
694+
695+ Default is ` false ` .
696+
697+ - [ ** ` push_restrictions ` ** ] ( #attr-branch_protections_v4-push_restrictions ) : * (Optional ` list(string) ` )* <a name =" attr-branch_protections_v4-push_restrictions " ></a >
698+
699+ The list of actor Names/IDs that may push to the branch.
700+ Actor names must either begin with a "/" for users or the organization name followed by a "/" for teams.
701+
702+ Default is ` [] ` .
703+
704+ - [ ** ` require_conversation_resolution ` ** ] ( #attr-branch_protections_v4-require_conversation_resolution ) : * (Optional ` bool ` )* <a name =" attr-branch_protections_v4-require_conversation_resolution " ></a >
705+
706+ Setting this to true requires all conversations on code must be resolved before a pull request can be merged.
707+
708+ Default is ` false ` .
709+
710+ - [ ** ` require_signed_commits ` ** ] ( #attr-branch_protections_v4-require_signed_commits ) : * (Optional ` bool ` )* <a name =" attr-branch_protections_v4-require_signed_commits " ></a >
711+
712+ Setting this to true requires all commits to be signed with GPG.
713+
714+ Default is ` false ` .
715+
716+ - [ ** ` required_linear_history ` ** ] ( #attr-branch_protections_v4-required_linear_history ) : * (Optional ` bool ` )* <a name =" attr-branch_protections_v4-required_linear_history " ></a >
717+
718+ Setting this to true enforces a linear commit Git history, which prevents anyone from pushing merge commits to a branch.
719+
720+ Default is ` false ` .
721+
722+ - [ ** ` required_pull_request_reviews ` ** ] ( #attr-branch_protections_v4-required_pull_request_reviews ) : * (Optional ` object(required_pull_request_reviews) ` )* <a name =" attr-branch_protections_v4-required_pull_request_reviews " ></a >
723+
724+ Enforce restrictions for pull request reviews.
725+
726+ Default is ` null ` .
727+
728+ The ` required_pull_request_reviews ` object accepts the following attributes:
729+
730+ - [ ** ` dismiss_stale_reviews ` ** ] ( #attr-branch_protections_v4-required_pull_request_reviews-dismiss_stale_reviews ) : * (Optional ` bool ` )* <a name =" attr-branch_protections_v4-required_pull_request_reviews-dismiss_stale_reviews " ></a >
731+
732+ Dismiss approved reviews automatically when a new commit is pushed.
733+
734+ Default is ` true ` .
735+
736+ - [ ** ` dismissal_restrictions ` ** ] ( #attr-branch_protections_v4-required_pull_request_reviews-dismissal_restrictions ) : * (Optional ` list(string) ` )* <a name =" attr-branch_protections_v4-required_pull_request_reviews-dismissal_restrictions " ></a >
737+
738+ The list of actor Names/IDs with dismissal access.
739+ If not empty, restrict_dismissals is ignored.
740+ Actor names must either begin with a "/" for users or the organization name followed by a "/" for teams.
741+
742+ Default is ` [] ` .
743+
744+ - [ ** ` pull_request_bypassers ` ** ] ( #attr-branch_protections_v4-required_pull_request_reviews-pull_request_bypassers ) : * (Optional ` list(string) ` )* <a name =" attr-branch_protections_v4-required_pull_request_reviews-pull_request_bypassers " ></a >
745+
746+ The list of actor Names/IDs that are allowed to bypass pull request requirements.
747+ Actor names must either begin with a "/" for users or the organization name followed by a "/" for teams.
748+
749+ Default is ` [] ` .
750+
751+ - [ ** ` require_code_owner_reviews ` ** ] ( #attr-branch_protections_v4-required_pull_request_reviews-require_code_owner_reviews ) : * (Optional ` bool ` )* <a name =" attr-branch_protections_v4-required_pull_request_reviews-require_code_owner_reviews " ></a >
752+
753+ Require an approved review in pull requests including files with a designated code owner.
754+
755+ Default is ` false ` .
756+
757+ - [ ** ` required_approving_review_count ` ** ] ( #attr-branch_protections_v4-required_pull_request_reviews-required_approving_review_count ) : * (Optional ` number ` )* <a name =" attr-branch_protections_v4-required_pull_request_reviews-required_approving_review_count " ></a >
758+
759+ Require x number of approvals to satisfy branch protection requirements.
760+ If this is specified it must be a number between 0-6.
761+
762+ Default is ` 0 ` .
763+
764+ - [ ** ` required_status_checks ` ** ] ( #attr-branch_protections_v4-required_status_checks ) : * (Optional ` object(required_status_checks) ` )* <a name =" attr-branch_protections_v4-required_status_checks " ></a >
765+
766+ Enforce restrictions for required status checks.
767+ See Required Status Checks below for details.
768+
769+ Default is ` null ` .
770+
771+ The ` required_status_checks ` object accepts the following attributes:
772+
773+ - [ ** ` strict ` ** ] ( #attr-branch_protections_v4-required_status_checks-strict ) : * (Optional ` bool ` )* <a name =" attr-branch_protections_v4-required_status_checks-strict " ></a >
774+
775+ Require branches to be up to date before merging.
776+
777+ Default is ` false ` .
778+
779+ - [ ** ` contexts ` ** ] ( #attr-branch_protections_v4-required_status_checks-contexts ) : * (Optional ` list(string) ` )* <a name =" attr-branch_protections_v4-required_status_checks-contexts " ></a >
780+
781+ The list of status checks to require in order to merge into this branch. If default is ` [] ` no status checks are required.
782+
783+ Default is ` [] ` .
784+
655785#### Issue Labels Configuration
656786
657787- [ ** ` issue_labels ` ** ] ( #var-issue_labels ) : * (Optional ` list(issue_label) ` )* <a name =" var-issue_labels " ></a >
0 commit comments