Skip to content

Commit f7aaf46

Browse files
committed
feat!: Add support for allow_update_branch
1 parent ee6001a commit f7aaf46

File tree

11 files changed

+63
-27
lines changed

11 files changed

+63
-27
lines changed

.tflint.hcl

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rule "terraform_unused_declarations" {
2+
enabled = false
3+
}
4+
5+
rule "terraform_required_providers" {
6+
enabled = false
7+
}

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add support for `allow_update_branch`.
13+
14+
### Changed
15+
16+
- BREAKING CHANGE: Bump minimum supported version of the GitHub provider to `v5.16`
17+
as it contains a [critical fix](https://github.com/integrations/terraform-provider-github/pull/1415) for branch protections.
18+
1019
## [0.18.0]
1120

1221
### Added

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Build Status](https://github.com/mineiros-io/terraform-github-repository/workflows/CI/CD%20Pipeline/badge.svg)](https://github.com/mineiros-io/terraform-github-repository/actions)
44
[![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/mineiros-io/terraform-github-repository.svg?label=latest&sort=semver)](https://github.com/mineiros-io/terraform-github-repository/releases)
55
[![Terraform Version](https://img.shields.io/badge/terraform-1.x-623CE4.svg?logo=terraform)](https://github.com/hashicorp/terraform/releases)
6-
[![Github Provider Version](https://img.shields.io/badge/GH-4.10+-F8991D.svg?logo=terraform)](https://github.com/terraform-providers/terraform-provider-github/releases)
6+
[![Github Provider Version](https://img.shields.io/badge/GH-5.16+-F8991D.svg?logo=terraform)](https://github.com/terraform-providers/terraform-provider-github/releases)
77
[![Join Slack](https://img.shields.io/badge/slack-@mineiros--community-f32752.svg?logo=slack)](https://join.slack.com/t/mineiros-community/shared_invite/zt-ehidestg-aLGoIENLVs6tvwJ11w9WGg)
88

99
# terraform-github-repository
@@ -649,6 +649,12 @@ This is due to some terraform limitation and we will update the module once terr
649649

650650
Default is `false`.
651651

652+
- [**`allow_update_branch`**](#attr-branch_protections_v4-allow_update_branch): *(Optional `bool`)*<a name="attr-branch_protections_v4-allow_update_branch"></a>
653+
654+
Set to `true` to always suggest updating pull request branches.
655+
656+
Default is `false`.
657+
652658
- [**`blocks_creations`**](#attr-branch_protections_v4-blocks_creations): *(Optional `bool`)*<a name="attr-branch_protections_v4-blocks_creations"></a>
653659

654660
Setting this to `true` will block creating the branch.
@@ -1078,7 +1084,7 @@ Run `make help` to see details on each available target.
10781084
This module is licensed under the Apache License Version 2.0, January 2004.
10791085
Please see [LICENSE] for full details.
10801086

1081-
Copyright &copy; 2020-2022 [Mineiros GmbH][homepage]
1087+
Copyright &copy; 2020-2023 [Mineiros GmbH][homepage]
10821088

10831089

10841090
<!-- References -->
@@ -1097,7 +1103,7 @@ Copyright &copy; 2020-2022 [Mineiros GmbH][homepage]
10971103
[badge-license]: https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg
10981104
[badge-terraform]: https://img.shields.io/badge/terraform-1.x-623CE4.svg?logo=terraform
10991105
[badge-slack]: https://img.shields.io/badge/slack-@mineiros--community-f32752.svg?logo=slack
1100-
[badge-tf-gh]: https://img.shields.io/badge/GH-4.10+-F8991D.svg?logo=terraform
1106+
[badge-tf-gh]: https://img.shields.io/badge/GH-5.16+-F8991D.svg?logo=terraform
11011107
[releases-github-provider]: https://github.com/terraform-providers/terraform-provider-github/releases
11021108
[build-status]: https://github.com/mineiros-io/terraform-github-repository/actions
11031109
[releases-github]: https://github.com/mineiros-io/terraform-github-repository/releases

README.tfdoc.hcl

+11-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ header {
2121
}
2222

2323
badge "tf-gh" {
24-
image = "https://img.shields.io/badge/GH-4.10+-F8991D.svg?logo=terraform"
24+
image = "https://img.shields.io/badge/GH-5.16+-F8991D.svg?logo=terraform"
2525
url = "https://github.com/terraform-providers/terraform-provider-github/releases"
2626
text = "Github Provider Version"
2727
}
@@ -837,6 +837,14 @@ section {
837837
END
838838
}
839839

840+
attribute "allow_update_branch" {
841+
type = bool
842+
default = false
843+
description = <<-END
844+
Set to `true` to always suggest updating pull request branches.
845+
END
846+
}
847+
840848
attribute "blocks_creations" {
841849
type = bool
842850
default = false
@@ -1442,7 +1450,7 @@ section {
14421450
This module is licensed under the Apache License Version 2.0, January 2004.
14431451
Please see [LICENSE] for full details.
14441452
1445-
Copyright &copy; 2020-2022 [Mineiros GmbH][homepage]
1453+
Copyright &copy; 2020-2023 [Mineiros GmbH][homepage]
14461454
END
14471455
}
14481456
}
@@ -1491,7 +1499,7 @@ references {
14911499
value = "https://img.shields.io/badge/slack-@mineiros--community-f32752.svg?logo=slack"
14921500
}
14931501
ref "badge-tf-gh" {
1494-
value = "https://img.shields.io/badge/GH-4.10+-F8991D.svg?logo=terraform"
1502+
value = "https://img.shields.io/badge/GH-5.16+-F8991D.svg?logo=terraform"
14951503
}
14961504
ref "releases-github-provider" {
14971505
value = "https://github.com/terraform-providers/terraform-provider-github/releases"

examples/public-repository/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Run `terraform destroy` to destroy all resources again.
111111
[main.tf]: https://github.com/mineiros-io/terraform-github-repository/blob/main/examples/public-respository/main.tf
112112
[homepage]: https://mineiros.io/?ref=terraform-github-repository
113113
[badge-license]: https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg
114-
[badge-terraform]: https://img.shields.io/badge/terraform-1.x%20|0.15%20|0.14%20|%200.13%20|%200.12.20+-623CE4.svg?logo=terraform
114+
[badge-terraform]: https://img.shields.io/badge/terraform-1.x-623CE4.svg?logo=terraform
115115
[badge-slack]: https://img.shields.io/badge/slack-@mineiros--community-f32752.svg?logo=slack
116116
[releases-terraform]: https://github.com/hashicorp/terraform/releases
117117
[apache20]: https://opensource.org/licenses/Apache-2.0

examples/public-repository/main.tf

+17-16
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,23 @@ module "repository" {
1313
module.team
1414
]
1515

16-
name = "my-public-repository"
17-
description = "A description of the repository."
18-
homepage_url = "https://github.com/mineiros-io"
19-
visibility = "public"
20-
has_issues = true
21-
has_projects = false
22-
has_wiki = true
23-
allow_merge_commit = true
24-
allow_rebase_merge = false
25-
allow_squash_merge = false
26-
allow_auto_merge = true
27-
has_downloads = false
28-
auto_init = true
29-
gitignore_template = "Terraform"
30-
license_template = "mit"
31-
topics = ["terraform", "unit-test"]
16+
name = "my-public-repository"
17+
description = "A description of the repository."
18+
homepage_url = "https://github.com/mineiros-io"
19+
visibility = "public"
20+
has_issues = true
21+
has_projects = false
22+
has_wiki = true
23+
allow_merge_commit = true
24+
allow_rebase_merge = false
25+
allow_squash_merge = false
26+
allow_auto_merge = true
27+
has_downloads = false
28+
auto_init = true
29+
gitignore_template = "Terraform"
30+
license_template = "mit"
31+
topics = ["terraform", "unit-test"]
32+
allow_update_branch = true
3233

3334
admin_team_ids = [
3435
module.team.team.id

main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ resource "github_repository" "repository" {
108108
license_template = local.license_template
109109
archived = var.archived
110110
topics = local.topics
111+
allow_update_branch = var.allow_update_branch
111112

112113
archive_on_destroy = var.archive_on_destroy
113114
vulnerability_alerts = local.vulnerability_alerts

test/unit-complete/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ module "repository" {
4040
allow_rebase_merge = var.allow_rebase_merge
4141
allow_squash_merge = var.allow_squash_merge
4242
allow_auto_merge = var.allow_auto_merge
43+
allow_update_branch = true
4344
delete_branch_on_merge = var.delete_branch_on_merge
4445
is_template = var.is_template
4546
has_downloads = var.has_downloads

test/unit-complete/provider.tf

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ terraform {
66
required_providers {
77
github = {
88
source = "integrations/github"
9-
# mask providers with broken branch protection v3 imlementation
10-
version = "~> 5.0, !=5.3.0, !=5.4.0, !=5.5.0, !=5.6.0, !=5.7.0"
119
}
1210
tls = {
1311
source = "hashicorp/tls"

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ variable "allow_auto_merge" {
9696
default = null
9797
}
9898

99+
variable "allow_update_branch" {
100+
description = "(Optional) Set to true to always suggest updating pull request branches."
101+
type = bool
102+
default = false
103+
}
104+
99105
variable "delete_branch_on_merge" {
100106
description = "(Optional) Whether or not to delete the merged branch after merging a pull request. (Default: false)"
101107
type = bool

versions.tf

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
terraform {
66
required_version = "~> 1.0"
77

8-
# branch_protections_v3 are broken in >= 5.3
98
required_providers {
109
github = {
1110
source = "integrations/github"
12-
version = ">= 4.20, < 6.0"
11+
version = ">= 5.16, < 6.0"
1312
}
1413
}
1514
}

0 commit comments

Comments
 (0)