Skip to content

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

@megamih

Description

@megamih

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:

  • Repository admins or organization owners
  • The maintain or write role, or custom repository roles based on the write role
  • Teams
  • Deploy keys
  • GitHub Apps
  • Dependabot

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions