pin every github org setting and gate org resources on config.yaml
This commit is contained in:
@@ -298,17 +298,54 @@ run "org_settings_unmanaged_without_config" {
|
||||
command = plan
|
||||
|
||||
assert {
|
||||
condition = length(github_organization_settings.this) == 0 && length(github_actions_runner_group.default) == 0
|
||||
error_message = "org settings and the default runner group must stay unmanaged without config.yaml"
|
||||
condition = (
|
||||
length(github_organization_settings.this) == 0 &&
|
||||
length(github_actions_runner_group.default) == 0 &&
|
||||
length(github_actions_organization_workflow_permissions.this) == 0
|
||||
)
|
||||
error_message = "org settings, workflow permissions and the default runner group must stay unmanaged without config.yaml"
|
||||
}
|
||||
}
|
||||
|
||||
run "org_settings_pinned" {
|
||||
command = plan
|
||||
|
||||
variables {
|
||||
settings = { billing_email = "ops@example.com", name = "IUCLabs", description = "Labs" }
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = (
|
||||
github_actions_organization_workflow_permissions.this.default_workflow_permissions == "read" &&
|
||||
!github_actions_organization_workflow_permissions.this.can_approve_pull_request_reviews
|
||||
github_actions_organization_workflow_permissions.this[0].default_workflow_permissions == "read" &&
|
||||
!github_actions_organization_workflow_permissions.this[0].can_approve_pull_request_reviews
|
||||
)
|
||||
error_message = "GITHUB_TOKEN must default to read-only and never approve PRs"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = (
|
||||
github_organization_settings.this[0].name == "IUCLabs" &&
|
||||
github_organization_settings.this[0].description == "Labs" &&
|
||||
github_organization_settings.this[0].blog == null
|
||||
)
|
||||
error_message = "profile fields must come from config, unset ones stay null"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = alltrue([for f in [
|
||||
"members_can_create_pages", "members_can_create_public_pages", "members_can_create_private_pages",
|
||||
"members_can_fork_private_repositories", "has_repository_projects", "web_commit_signoff_required",
|
||||
"advanced_security_enabled_for_new_repositories", "dependabot_alerts_enabled_for_new_repositories",
|
||||
"dependabot_security_updates_enabled_for_new_repositories", "dependency_graph_enabled_for_new_repositories",
|
||||
"secret_scanning_enabled_for_new_repositories", "secret_scanning_push_protection_enabled_for_new_repositories",
|
||||
] : github_organization_settings.this[0][f] == false])
|
||||
error_message = "pages, private forks, repo projects, signoff and legacy security toggles must be pinned false"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = github_organization_settings.this[0].has_organization_projects == true
|
||||
error_message = "organization projects must stay enabled"
|
||||
}
|
||||
}
|
||||
|
||||
run "org_settings_from_config" {
|
||||
|
||||
Reference in New Issue
Block a user