integrations / terraform-provider-github

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

[FEAT]: Add DeployKey to bypass_actors in github_organization_ruleset and github_repository_ruleset #2254

Open megamih opened 5 months ago

megamih commented 5 months ago

Describe the need

According to GitHub docummentation for creating rulesets for repositories in your organization and REST API for managing rulesets for organizations and repositories the following are eligible for bypass access:

And Terraform GitHub provider lacks support for Deploy keys.

resource "github_organization_ruleset" "test" {
    name        = "test-%s"
    target      = "branch"
    enforcement = "active"

    conditions {
        ref_name {
            include = ["~ALL"]
            exclude = []
        }
    }

    bypass_actors {
        actor_id    = 0
        actor_type  = "DeployKey"
        bypass_mode = "always"
    }

    rules {
        creation = true

        update = true

        deletion                = true
        required_linear_history = true

        required_signatures = false

        pull_request {
            required_approving_review_count   = 2
            required_review_thread_resolution = true
            require_code_owner_review         = true
            dismiss_stale_reviews_on_push     = true
            require_last_push_approval        = true
        }

        required_status_checks {

            required_check {
                context = "ci"
            }

            strict_required_status_checks_policy = true
        }

        branch_name_pattern {
            name     = "test"
            negate   = false
            operator = "starts_with"
            pattern  = "test"
        }

        non_fast_forward = true
    }
}

returns an error

│ Error: expected bypass_actors.0.actor_type to be one of [RepositoryRole Team Integration OrganizationAdmin], got DeployKey

SDK Version

No response

API Version

2022-11-28

Relevant log output

│ Error: expected bypass_actors.0.actor_type to be one of [RepositoryRole Team Integration OrganizationAdmin], got DeployKey


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct