Skip to content

Commit 9f305fb

Browse files
authored
Add allow_auto_merge option for repositories (#923)
Support enabling auto-merge on a repository as per #649
1 parent ff54c61 commit 9f305fb

File tree

5 files changed

+21
-0
lines changed

5 files changed

+21
-0
lines changed

github/data_source_github_repository.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ func dataSourceGithubRepository() *schema.Resource {
7373
Type: schema.TypeBool,
7474
Computed: true,
7575
},
76+
"allow_auto_merge": {
77+
Type: schema.TypeBool,
78+
Computed: true,
79+
},
7680
"default_branch": {
7781
Type: schema.TypeString,
7882
Computed: true,
@@ -216,6 +220,7 @@ func dataSourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) er
216220
d.Set("allow_merge_commit", repo.GetAllowMergeCommit())
217221
d.Set("allow_squash_merge", repo.GetAllowSquashMerge())
218222
d.Set("allow_rebase_merge", repo.GetAllowRebaseMerge())
223+
d.Set("allow_auto_merge", repo.GetAllowAutoMerge())
219224
d.Set("has_downloads", repo.GetHasDownloads())
220225
d.Set("full_name", repo.GetFullName())
221226
d.Set("default_branch", repo.GetDefaultBranch())

github/resource_github_repository.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ func resourceGithubRepository() *schema.Resource {
8888
Optional: true,
8989
Default: true,
9090
},
91+
"allow_auto_merge": {
92+
Type: schema.TypeBool,
93+
Optional: true,
94+
Default: false,
95+
},
9196
"delete_branch_on_merge": {
9297
Type: schema.TypeBool,
9398
Optional: true,
@@ -268,6 +273,7 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository {
268273
AllowMergeCommit: github.Bool(d.Get("allow_merge_commit").(bool)),
269274
AllowSquashMerge: github.Bool(d.Get("allow_squash_merge").(bool)),
270275
AllowRebaseMerge: github.Bool(d.Get("allow_rebase_merge").(bool)),
276+
AllowAutoMerge: github.Bool(d.Get("allow_auto_merge").(bool)),
271277
DeleteBranchOnMerge: github.Bool(d.Get("delete_branch_on_merge").(bool)),
272278
AutoInit: github.Bool(d.Get("auto_init").(bool)),
273279
LicenseTemplate: github.String(d.Get("license_template").(string)),
@@ -416,6 +422,7 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro
416422
d.Set("allow_merge_commit", repo.GetAllowMergeCommit())
417423
d.Set("allow_squash_merge", repo.GetAllowSquashMerge())
418424
d.Set("allow_rebase_merge", repo.GetAllowRebaseMerge())
425+
d.Set("allow_auto_merge", repo.GetAllowAutoMerge())
419426
d.Set("delete_branch_on_merge", repo.GetDeleteBranchOnMerge())
420427
d.Set("has_downloads", repo.GetHasDownloads())
421428
d.Set("full_name", repo.GetFullName())

github/resource_github_repository_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func TestAccGithubRepositories(t *testing.T) {
3030
allow_merge_commit = true
3131
allow_squash_merge = false
3232
allow_rebase_merge = false
33+
allow_auto_merge = true
3334
auto_init = false
3435
3536
}
@@ -40,6 +41,10 @@ func TestAccGithubRepositories(t *testing.T) {
4041
"github_repository.test", "has_issues",
4142
"true",
4243
),
44+
resource.TestCheckResourceAttr(
45+
"github_repository.test", "allow_auto_merge",
46+
"true",
47+
),
4348
)
4449

4550
testCase := func(t *testing.T, mode string) {

website/docs/d/repository.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ The following arguments are supported:
4949

5050
* `allow_rebase_merge` - Whether the repository allows rebase merges.
5151

52+
* `allow_auto_merge` - Whether the repository allows auto-merging pull requests.
53+
5254
* `has_downloads` - Whether the repository has Downloads feature enabled.
5355

5456
* `default_branch` - The name of the default branch of the repository.

website/docs/r/repository.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ The following arguments are supported:
7575

7676
* `allow_rebase_merge` - (Optional) Set to `false` to disable rebase merges on the repository.
7777

78+
* `allow_auto_merge` - (Optional) Set to `true` to allow auto-merging pull requests on the repository.
79+
7880
* `delete_branch_on_merge` - (Optional) Automatically delete head branch after a pull request is merged. Defaults to `false`.
7981

8082
* `has_downloads` - (Optional) Set to `true` to enable the (deprecated) downloads features on the repository.

0 commit comments

Comments
 (0)