Skip to content

Commit 0c6ba30

Browse files
committed
update:README
1 parent bd7aa5b commit 0c6ba30

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

README.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ terraform {
99
required_providers {
1010
kwgithub = {
1111
source = "knowledge-work/kw-github"
12-
// version = "0.0.5"
1312
}
1413
}
1514
}
@@ -21,8 +20,8 @@ terraform {
2120

2221
```hcl
2322
provider "kwgithub" {
24-
token = var.github_token
2523
owner = "knowledge-work"
24+
token = var.github_token
2625
}
2726
```
2827

@@ -73,16 +72,36 @@ resource "kwgithub_ruleset_allowed_merge_methods" "example" {
7372
ruleset_id = github_repository_ruleset.example.ruleset_id
7473
allowed_merge_methods = ["merge", "squash"]
7574
76-
# Recommended: GitHub resets allowed_merge_methods when ruleset is updated
77-
force_update = timestamp()
75+
# Recommended: Update only when ruleset configuration changes
76+
force_update = sha256(jsonencode({
77+
name = github_repository_ruleset.example.name
78+
target = github_repository_ruleset.example.target
79+
enforcement = github_repository_ruleset.example.enforcement
80+
conditions = github_repository_ruleset.example.conditions
81+
rules = github_repository_ruleset.example.rules
82+
}))
7883
7984
depends_on = [github_repository_ruleset.example]
8085
}
8186
```
8287

83-
### ⚠️Important: Force Update Recommendation
88+
### ⚠️ Important: Force Update Recommendation
89+
90+
It is strongly recommended to include a `force_update` parameter in your resource configuration. This ensures the resource is updated when the ruleset configuration changes, which is necessary because GitHub's API specification causes `allowed_merge_methods` to be reset whenever `github_repository_ruleset` is updated.
91+
92+
Use a hash of the ruleset configuration to trigger updates only when the ruleset actually changes:
93+
94+
```hcl
95+
force_update = sha256(jsonencode({
96+
name = github_repository_ruleset.example.name
97+
target = github_repository_ruleset.example.target
98+
enforcement = github_repository_ruleset.example.enforcement
99+
conditions = github_repository_ruleset.example.conditions
100+
rules = github_repository_ruleset.example.rules
101+
}))
102+
```
84103

85-
It is strongly recommended to include `force_update = timestamp()` in your resource configuration. This ensures the resource is updated on every Terraform run, which is necessary because GitHub's API specification causes `allowed_merge_methods` to be reset whenever `github_repository_ruleset` is updated. Without `force_update`, your merge method configuration may be unexpectedly lost when other ruleset changes are applied.
104+
This approach avoids unnecessary updates while ensuring merge method configuration is restored when needed.
86105

87106
## Why This Provider?
88107

0 commit comments

Comments
 (0)