terraform-provider-github icon indicating copy to clipboard operation
terraform-provider-github copied to clipboard

Add branch pattern example to repository_ruleset documentation

Open chemmi opened this issue 6 months ago • 0 comments

The pattern can be confusing since Github API and UI differ in this point. This is just a clarification for the documentation.

See also: https://github.com/orgs/community/discussions/119797 See also: https://docs.github.com/en/rest/repos/rules#create-a-repository-ruleset

Resolves #ISSUE_NUMBER


Before the change?

  • Intuitively, the user would use the simple branch pattern main oder feat-* to include or exclude branches in the ruleset. The provider will crash with a 402 when applying the change:
Error: POST https://api.github.com/repos/ORG/REPO/rulesets: 422 Validation Failed [{Resource: Field: Code: Message:Invalid target patterns: 'main'}]

After the change?

  • The documentation suggests to use the required pattern, e.g. refs/heads/main, in this case.

See also the example in https://docs.github.com/en/rest/repos/rules#create-a-repository-ruleset which uses this pattern.

Pull request checklist

  • [ ] Tests for the changes have been added (for bug fixes / features)
  • [x] Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • [ ] Yes
  • [x] No

chemmi avatar May 15 '25 05:05 chemmi