diff --git a/github/resource_github_repository.go b/github/resource_github_repository.go index 54218f8901..0a5dbe595f 100644 --- a/github/resource_github_repository.go +++ b/github/resource_github_repository.go @@ -204,6 +204,12 @@ func resourceGithubRepository() *schema.Resource { Default: false, Description: "Automatically delete head branch after a pull request is merged. Defaults to 'false'.", }, + "web_commit_signoff_required": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Require contributors to sign off on web-based commits. Defaults to 'false'.", + }, "auto_init": { Type: schema.TypeBool, Optional: true, @@ -470,28 +476,29 @@ func calculateSecurityAndAnalysis(d *schema.ResourceData) *github.SecurityAndAna func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository { repository := &github.Repository{ - Name: github.String(d.Get("name").(string)), - Description: github.String(d.Get("description").(string)), - Homepage: github.String(d.Get("homepage_url").(string)), - Visibility: github.String(calculateVisibility(d)), - HasDownloads: github.Bool(d.Get("has_downloads").(bool)), - HasIssues: github.Bool(d.Get("has_issues").(bool)), - HasDiscussions: github.Bool(d.Get("has_discussions").(bool)), - HasProjects: github.Bool(d.Get("has_projects").(bool)), - HasWiki: github.Bool(d.Get("has_wiki").(bool)), - IsTemplate: github.Bool(d.Get("is_template").(bool)), - AllowMergeCommit: github.Bool(d.Get("allow_merge_commit").(bool)), - AllowSquashMerge: github.Bool(d.Get("allow_squash_merge").(bool)), - AllowRebaseMerge: github.Bool(d.Get("allow_rebase_merge").(bool)), - AllowAutoMerge: github.Bool(d.Get("allow_auto_merge").(bool)), - DeleteBranchOnMerge: github.Bool(d.Get("delete_branch_on_merge").(bool)), - AutoInit: github.Bool(d.Get("auto_init").(bool)), - LicenseTemplate: github.String(d.Get("license_template").(string)), - GitignoreTemplate: github.String(d.Get("gitignore_template").(string)), - Archived: github.Bool(d.Get("archived").(bool)), - Topics: expandStringList(d.Get("topics").(*schema.Set).List()), - AllowUpdateBranch: github.Bool(d.Get("allow_update_branch").(bool)), - SecurityAndAnalysis: calculateSecurityAndAnalysis(d), + Name: github.String(d.Get("name").(string)), + Description: github.String(d.Get("description").(string)), + Homepage: github.String(d.Get("homepage_url").(string)), + Visibility: github.String(calculateVisibility(d)), + HasDownloads: github.Bool(d.Get("has_downloads").(bool)), + HasIssues: github.Bool(d.Get("has_issues").(bool)), + HasDiscussions: github.Bool(d.Get("has_discussions").(bool)), + HasProjects: github.Bool(d.Get("has_projects").(bool)), + HasWiki: github.Bool(d.Get("has_wiki").(bool)), + IsTemplate: github.Bool(d.Get("is_template").(bool)), + AllowMergeCommit: github.Bool(d.Get("allow_merge_commit").(bool)), + AllowSquashMerge: github.Bool(d.Get("allow_squash_merge").(bool)), + AllowRebaseMerge: github.Bool(d.Get("allow_rebase_merge").(bool)), + AllowAutoMerge: github.Bool(d.Get("allow_auto_merge").(bool)), + DeleteBranchOnMerge: github.Bool(d.Get("delete_branch_on_merge").(bool)), + WebCommitSignoffRequired: github.Bool(d.Get("web_commit_signoff_required").(bool)), + AutoInit: github.Bool(d.Get("auto_init").(bool)), + LicenseTemplate: github.String(d.Get("license_template").(string)), + GitignoreTemplate: github.String(d.Get("gitignore_template").(string)), + Archived: github.Bool(d.Get("archived").(bool)), + Topics: expandStringList(d.Get("topics").(*schema.Set).List()), + AllowUpdateBranch: github.Bool(d.Get("allow_update_branch").(bool)), + SecurityAndAnalysis: calculateSecurityAndAnalysis(d), } // only configure merge commit if we are in commit merge strategy @@ -678,6 +685,7 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro d.Set("allow_squash_merge", repo.GetAllowSquashMerge()) d.Set("allow_update_branch", repo.GetAllowUpdateBranch()) d.Set("delete_branch_on_merge", repo.GetDeleteBranchOnMerge()) + d.Set("web_commit_signoff_required", repo.GetWebCommitSignoffRequired()) d.Set("has_downloads", repo.GetHasDownloads()) d.Set("merge_commit_message", repo.GetMergeCommitMessage()) d.Set("merge_commit_title", repo.GetMergeCommitTitle()) diff --git a/github/resource_github_repository_test.go b/github/resource_github_repository_test.go index bab9cf7b0c..0f8e0b4fc7 100644 --- a/github/resource_github_repository_test.go +++ b/github/resource_github_repository_test.go @@ -25,20 +25,20 @@ func TestAccGithubRepositories(t *testing.T) { config := fmt.Sprintf(` resource "github_repository" "test" { - name = "tf-acc-test-create-%[1]s" - description = "Terraform acceptance tests %[1]s" - has_discussions = true - has_issues = true - has_wiki = true - has_downloads = true - allow_merge_commit = true - allow_squash_merge = false - allow_rebase_merge = false - allow_auto_merge = true - merge_commit_title = "MERGE_MESSAGE" - merge_commit_message = "PR_TITLE" - auto_init = false - + name = "tf-acc-test-create-%[1]s" + description = "Terraform acceptance tests %[1]s" + has_discussions = true + has_issues = true + has_wiki = true + has_downloads = true + allow_merge_commit = true + allow_squash_merge = false + allow_rebase_merge = false + allow_auto_merge = true + merge_commit_title = "MERGE_MESSAGE" + merge_commit_message = "PR_TITLE" + auto_init = false + web_commit_signoff_required = true } `, randomID) @@ -59,6 +59,10 @@ func TestAccGithubRepositories(t *testing.T) { "github_repository.test", "merge_commit_title", "MERGE_MESSAGE", ), + resource.TestCheckResourceAttr( + "github_repository.test", "web_commit_signoff_required", + "true", + ), ) testCase := func(t *testing.T, mode string) { diff --git a/website/docs/r/repository.html.markdown b/website/docs/r/repository.html.markdown index adef0129d6..344e341baf 100644 --- a/website/docs/r/repository.html.markdown +++ b/website/docs/r/repository.html.markdown @@ -94,6 +94,8 @@ The following arguments are supported: * `delete_branch_on_merge` - (Optional) Automatically delete head branch after a pull request is merged. Defaults to `false`. +* `web_commit_signoff_required` - (Optional) Require contributors to sign off on web-based commits. See more [here](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/managing-the-commit-signoff-policy-for-your-repository). Defaults to `false`. + * `has_downloads` - (Optional) Set to `true` to enable the (deprecated) downloads features on the repository. * `auto_init` - (Optional) Set to `true` to produce an initial commit in the repository.