integrations / terraform-provider-github

Terraform GitHub provider
https://www.terraform.io/docs/providers/github/
MIT License
902 stars 743 forks source link

[Feature Request] "github_repository" default merge action #1024

Open jfreeland opened 2 years ago

jfreeland commented 2 years ago

I would like to be able to have the default merge action for a repo created with github_repository have a default merge action that is configurable.

By default I want users to Squash and Merge but I don't want to disallow allow_merge_commit or allow_rebase_merge.

In my experience, GitHub repos default to Merge pull request (Create a merge commit), retaining the history of all previous commits, until the user clicks the green dropdown and selects Squash and merge at least once. This has me concerned that this could be a per-user setting but I would like to be able to set the default on a per-repo (per org?) basis.

Affected Resource(s)

Terraform Configuration Files

resource "github_repository" "example" {
  name        = "example"
  description = "My awesome codebase"

  visibility = "public"

  allow_merge_commit = true
  allow_squash_merge = true
  allow_rebase_merge = true
  default_merge_action = "squash_merge"
}

Related

github-actions[bot] commented 1 year ago

👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

Horgix commented 1 year ago

@jfreeland , I would also have loved such a feature but if I'm not mistaken, this feature doesn't exist on GitHub itself, therefore making it impossible to support this in this Terraform provider?

The GitHub feature request is here: https://github.com/community/community/discussions/20583

From my understanding, the current behavior is that the default merge action is only set on a per-user basis (last selected option for a repository is the proposed default action).

Did I miss something?

2 additional notes:

Krusty93 commented 8 months ago

It seems now implemented by GitHub: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/configuring-commit-squashing-for-pull-requests