Skip to content

Commit

Permalink
terraform: add infra repo and ruleset
Browse files Browse the repository at this point in the history
  • Loading branch information
zowoq committed Feb 3, 2025
1 parent 6d9ec7c commit 5451a2d
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
85 changes: 85 additions & 0 deletions terraform/github-repo-infra.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
resource "github_repository" "infra" {
name = "infra"
description = "nix-community infrastructure [maintainer=@zowoq]"
homepage_url = "https://nix-community.org"

topics = [
"nix-community-buildbot",
"nix-darwin",
"nixos",
"terraform",
]

allow_auto_merge = true
allow_merge_commit = false
allow_rebase_merge = true
allow_squash_merge = false
delete_branch_on_merge = true
has_discussions = true
has_issues = true
vulnerability_alerts = true


pages {
build_type = "workflow"
cname = "nix-community.org"

source {
branch = "master"
path = "/"
}
}
}

resource "github_repository_ruleset" "infra" {
name = "default branch"
repository = github_repository.infra.name
target = "branch"
enforcement = "active"

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

rules {
deletion = true
non_fast_forward = true

merge_queue {
check_response_timeout_minutes = 60
grouping_strategy = "ALLGREEN"
max_entries_to_build = 1
max_entries_to_merge = 1
merge_method = "REBASE"
min_entries_to_merge = 1
min_entries_to_merge_wait_minutes = 5
}

pull_request {
required_approving_review_count = 0
required_review_thread_resolution = false
require_code_owner_review = false
dismiss_stale_reviews_on_push = false
require_last_push_approval = false
}

required_status_checks {
required_check {
context = "buildbot/nix-build"
}
}
}
}

import {
to = github_repository.infra
id = "infra"
}

# import {
# to = github_repository_ruleset.example
# id = "example:12345"
# }
9 changes: 9 additions & 0 deletions terraform/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
packages = [
(terraform.withPlugins (p: [
p.cloudflare
(p.github.overrideAttrs (_: {
patches = [
(fetchpatch {
name = "add-support-for-merge-queues-in-repository-rulesets.patch";
url = "https://github.com/integrations/terraform-provider-github/pull/2380.patch";
hash = "sha256-aauj8YCybuH2iDNVIb/q4hNbs1rsTS2qNYNvQLbrZ7Q=";
})
];
}))
p.hydra
p.sops
p.tfe
Expand Down
8 changes: 8 additions & 0 deletions terraform/terraform_providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ terraform {
cloudflare = {
source = "cloudflare/cloudflare"
}
github = {
source = "integrations/github"
}
hydra = {
source = "DeterminateSystems/hydra"
}
Expand All @@ -29,6 +32,11 @@ provider "hydra" {
username = "admin"
}

provider "github" {
# admin provides their own token
owner = "nix-community"
}

provider "tfe" {
token = data.sops_file.nix-community.data["TFE_TOKEN"]
}

0 comments on commit 5451a2d

Please sign in to comment.