Skip to content

Commit e1d467b

Browse files
authored
Fix creation of release branches (#31)
* Do not enforce status checks and workflows on create When enforcing status checks and workflows on creation, it becomes impossible to create new release branches or push the initial commit to main of a newly created repo. Signed-off-by: Daniel Gonzalez Nothnagel <daniel.gonzalez.nothnagel@sap.com> * Do not enforce linear history When the default branch contains a merge commit in its history, it will become impossible to create release branches with linear history. Signed-off-by: Daniel Gonzalez Nothnagel <daniel.gonzalez.nothnagel@sap.com> --------- Signed-off-by: Daniel Gonzalez Nothnagel <daniel.gonzalez.nothnagel@sap.com>
1 parent 13017ca commit e1d467b

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

automation/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ module "repositories" {
5555
}
5656
rules = {
5757
required_status_checks = {
58+
do_not_enforce_on_create = true
59+
5860
required_check = flatten([
5961
for app_slug, contexts in each.value.required_status_checks : [
6062
for context in contexts : {

automation/modules/github_repository/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ resource "github_repository_ruleset" "ruleset" {
5656
for_each = each.value.rules.required_status_checks != null ? [each.value.rules.required_status_checks] : []
5757
content {
5858
strict_required_status_checks_policy = required_status_checks.value.strict_required_status_checks_policy
59+
do_not_enforce_on_create = required_status_checks.value.do_not_enforce_on_create
5960

6061
dynamic "required_check" {
6162
for_each = required_status_checks.value.required_check

automation/modules/github_repository/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ variable "rulesets" {
9191

9292
required_status_checks = optional(object({
9393
strict_required_status_checks_policy = optional(bool)
94+
do_not_enforce_on_create = optional(bool)
9495
required_check = list(object({
9596
context = string
9697
integration_id = optional(number)

automation/rulesets.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ resource "github_organization_ruleset" "default_release" {
2323

2424
rules {
2525
deletion = true
26-
non_fast_forward = true
26+
# We can not enforce linear history on repos that have merge commits in their history.
27+
# Enforcing it will block creation of release branches.
28+
non_fast_forward = false
2729
required_linear_history = true
2830

2931
pull_request {
@@ -36,14 +38,16 @@ resource "github_organization_ruleset" "default_release" {
3638
}
3739

3840
required_status_checks {
41+
do_not_enforce_on_create = true
42+
3943
required_check {
4044
context = "DCO"
4145
integration_id = data.github_app.apps["dco"].id
4246
}
4347
}
4448

4549
required_workflows {
46-
do_not_enforce_on_create = false
50+
do_not_enforce_on_create = true
4751

4852
required_workflow {
4953
repository_id = module.repositories["community"].repo_id

0 commit comments

Comments
 (0)