Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

github-terraform

Manages GitHub repository settings and branch/tag protection for the jackin-project organization: 9 repositories, each with repository merge settings plus protect-main and protect-tags rulesets.

Layout

  • variables.tf — repository_policies inventory (single source of truth).
  • locals.tf — check_templates copy-paste source for check lists and their app ids.
  • repositories.tf — module.repository_policy wiring.
  • organization.tf — organization settings and Actions/workflow permissions.
  • modules/repository-policy/ — shared policy module (identical across orgs).
  • checks.tf — invariant guards (no scripts).
  • imports.tf — bootstrap import triples (one per repo: settings + 2 rulesets).
  • providers.tf, versions.tf, outputs.tf — provider, pins, outputs.

Authentication

Run tofu with GITHUB_TOKEN exported in the shell, or via the mise tasks mise run tofu:plan / mise run tofu:apply, which inject the organization token from 1Password. The token needs Administration: write on every managed repository. It also needs org admin on jackin-project for the organization settings and Actions policies in organization.tf.

Adding a repository

  1. Add one entry to repository_policies in variables.tf, copying a check list and its required_check_apps from locals.tf (standard = ["Required", "DCO"], policy = ["Policy"]); bespoke checks inline with a comment citing the producing workflow. Every required check must name the app that posts it in required_check_apps (validated), so no other job, app or commit status can satisfy it: Required and Policy come from GitHub Actions (15368), DCO from the cncf DCO-2 app (974774). Read ids from live data, never from memory: gh api repos/<repo>/commits/<sha>/check-runs --jq '.check_runs[] | {name, app: .app.slug, id: .app.id}'. strict_required_status_checks (default false) sets whether the branch must be up to date before merging; jackin and homebrew-tap set it true. Repos with no CI use required_checks = [] plus a non-empty no_ci_reason and extend the allowlist check in checks.tf. Always add the name to the mandatory list in mandatory_target_repositories_present in checks.tf (updating its count and message).
  2. Add one import triple (settings + protect_main + protect_tags) to imports.tf using the live numeric ruleset IDs.

Organization overlays

  • organization.tf manages the org profile (github_organization_settings), Actions availability/allow policy (github_actions_organization_permissions), and default GITHUB_TOKEN workflow permissions (github_actions_organization_workflow_permissions).

Verification

mise run check:tofu       # tofu fmt, init, validate: the CI OpenTofu job
mise run workflows        # velnor-gen --root . check: the CI Generated workflows job

CI is generated by velnor-gen from .velnor/rust-ci.toml; change that file and run velnor-gen --root . generate. The Required job gates the merge.

OpenTofu is pinned via mise.toml (opentofu 1.13.1); existing repos are imported via imports.tf on first apply.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages