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

Add support for providing a GitHub app as a pull request bypasser #1416

Conversation

strideynet
Copy link

@strideynet strideynet commented Dec 8, 2022

Potentially resolves #1156

Replaces PR #1202


Behavior

Before the change?

Configuring a GitHub App as a pull request bypasser will always state there is one change to make.

After the change?

After applying the Terraform once, it will not show as a change again.

Other information

Have a great day 🖖


Additional info

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Added the appropriate label for the given change

Does this introduce a breaking change?

No

Pull request type

Some might argue this is a bugfix, some might argue it's a new feature /shrug

Please add the corresponding label for change this PR introduces:

  • Feature/model/API additions: Type: Feature

Manual testing

I created an app named test-tf-branch-protection.

I applied:

terraform {
  required_providers {
    github = {
      source  = "integrations/github"
    }
  }
}

# Configure the GitHub Provider
provider "github" {}

resource "github_repository" "test" {
  name        = "test-tf"
  visibility = "public"
}

data "github_app" "app" {
  slug = "test-tf-branch-protection"
}

resource "github_branch_protection" "example" {
  repository_id = github_repository.test.node_id

  pattern          = "main"

  required_pull_request_reviews {
    required_approving_review_count = 1
    pull_request_bypassers = [data.github_app.app.node_id]
  }
}

The resulting config:

image

@strideynet
Copy link
Author

I cannot add labels so I am unable to complete your pull request checklist.

@strideynet strideynet marked this pull request as ready for review December 8, 2022 13:45
@strideynet
Copy link
Author

Hah, so it turns out this doesn't fix what I was trying to fix.

However, it does fix the diffing to prevent it trying to re-apply the addition of an app to the pull_request_bypasser.

@kfcampbell kfcampbell added Type: Feature New feature or request Type: Bug Something isn't working as documented labels Dec 8, 2022
@Nexus2k
Copy link

Nexus2k commented Dec 14, 2022

Any update on this? We're currently also running in the issue of not being able to add Github Apps in pull_request_bypassers list.

@audunsolemdal
Copy link

Hah, so it turns out this doesn't fix what I was trying to fix.

However, it does fix the diffing to prevent it trying to re-apply the addition of an app to the pull_request_bypasser.

This is very much appreciated for my part. Our tfplan is cluttered with false positives for re-applying apps that are already added as PR-bypassers

@strideynet
Copy link
Author

Any update on this? We're currently also running in the issue of not being able to add Github Apps in pull_request_bypassers list.

How are you trying to do this ? Are you using the app data source and then using the node id attribute of that ?

@audunsolemdal
Copy link

Any update on this? We're currently also running in the issue of not being able to add Github Apps in pull_request_bypassers list.

How are you trying to do this ? Are you using the app data source and then using the node id attribute of that ?

I tried getting this to work recently, but had some issues.

I get the node_id by the following method: #1248 (comment)

a bit time consuming for one-time jobs, but it works.

@kfcampbell
Copy link
Member

@strideynet I'm sorry, I saw this after merging #1453 with the same changes! I probably should've merged yours as you created your PR first.

@kfcampbell kfcampbell closed this Jan 3, 2023
@kfcampbell
Copy link
Member

I'll create a new release with these changes shortly so you can at least take advantage of them.

@strideynet strideynet deleted the strideynet/support-app-bypass-pull-request-branch-protection branch January 4, 2023 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented Type: Feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding the provider GitHub App to the branch protection exception list causes an error
4 participants