Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github_branch_protection is not creating restriction if only a single team is provided. #269

Closed
eduardohf-ciandt opened this issue Aug 13, 2019 · 5 comments
Labels
r/branch_protection Status: Stale Used by stalebot to clean house Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@eduardohf-ciandt
Copy link

Terraform Version

Terraform v0.12.3

  • provider.github v2.2.0

Affected Resource(s)

  • github_branch_protection

Terraform Configuration Files

locals {
    teams = ["admin"]
}

resource "github_repository" "repo" {
  name          = var.name
  description   = var.description
  private       = true
  auto_init     = false
  has_downloads = false
  has_issues    = false
  has_projects  = false
  has_wiki      = false
}

resource "github_branch_protection" "master_branch" {
  repository     = github_repository.repo.name
  branch         = "master"
  enforce_admins = true

  required_pull_request_reviews {
    dismiss_stale_reviews = true
    required_approving_review_count = 1
  }

  restrictions {
    teams = local.teams
  }
}

Expected Behavior

GitHub Branch should show the admin team in "Restrict who can push to matching branches" session.

Actual Behavior

No team is displayed in the "Restrict who can push to matching branches" session.

Steps to Reproduce

  1. terraform plan
  2. terraform apply

Important Factoids

I'm running using remote runners from TFE.

If I run with more than one team the team is properly associate in the "Restrict who can push to matching branches" session".

@iniinikoski
Copy link

Hmm, I'm working on the same topic here - but seems to work here... Will post more info soon...

@mmoscher
Copy link

For me some similar issue occurred: when a repo permissions for a team and a repo branch protection depending on the same team are created in the same run, the team is not listed in the branch protection. Deleting the protection and adding it (using terraform) again, works.

The official documentation states:
teams: (Optional) The list of team slugs with push access. Always use slug of the team, not its name. Each team already has to have access to the repository.

Thus I could image that their exists some kind of race-condition, because the team seems not to have the appropriate permissions during creation of the branch protection.

Maybe an depends_on could fix this.

@goloroden
Copy link

goloroden commented Dec 3, 2019

We have the same problem as @mmoscher, but with Terraform 0.12.16:

If you assign a repository to a team, and want to use that team for branch protection, the assignment works, but the team is not set for branch protection (it actually is set in the state file, but not on GitHub).

If you then unset the team for branch protection, apply, re-set it, and apply again, it's there.

So yes, our impression is as well that there is a race condition. We have not yet tried to fix this with depends_on, but of course it would be way nicer if the GitHub provider would solve this internally.

PS: Meanwhile we have tried it, and a depends_on seems to work as a workaround.

@jcudit jcudit added Type: Bug Something isn't working as documented r/branch_protection labels Dec 8, 2020
@github-actions
Copy link

👋 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!

@github-actions github-actions bot added the Status: Stale Used by stalebot to clean house label Dec 11, 2022
@kfcampbell kfcampbell added Status: Up for grabs Issues that are ready to be worked on by anyone Priority: Normal labels Dec 12, 2022
@github-actions github-actions bot removed the Status: Stale Used by stalebot to clean house label Dec 13, 2022
Copy link

👋 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!

@github-actions github-actions bot added the Status: Stale Used by stalebot to clean house label Apr 24, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r/branch_protection Status: Stale Used by stalebot to clean house Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

7 participants