Repository navigation
feat(policy): unify root layout and module contract (three-root parity) #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # jackin-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. | ||
| - `repositories.tf` — `module.repository_policy` wiring. | ||
| - `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. | ||
|
|
||
| ## Adding a repository | ||
|
|
||
| 1. Add one entry to `repository_policies` in `variables.tf`, copying a check | ||
| list from `locals.tf` (`standard` = `["Required", "DCO"]`, | ||
| `policy` = `["Policy"]`); bespoke checks inline with a comment citing the | ||
| producing workflow. Repos with no CI use `required_checks = []` plus a | ||
| non-empty `no_ci_reason` and extend the allowlist check in `checks.tf`. | ||
| 2. Add one import triple (settings + `protect_main` + `protect_tags`) to | ||
| `imports.tf` using the live numeric ruleset IDs. | ||
|
|
||
| ## Verification | ||
|
|
||
| ```sh | ||
| tofu fmt -check -recursive | ||
| tofu init -backend=false -input=false -lockfile=readonly | ||
| tofu validate -no-color | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| # Adopt the existing GitHub resources into the default local state before managing them. | ||
| # These stable IDs prevent a fresh state from planning duplicate repositories or rulesets. | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository.managed_settings["homebrew-tap"] | ||
| id = "homebrew-tap" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_main["homebrew-tap"] | ||
| id = "homebrew-tap:15170998" | ||
|
Comment on lines
+10
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_tags["homebrew-tap"] | ||
| id = "homebrew-tap:15179223" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository.managed_settings["jackin"] | ||
| id = "jackin" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_main["jackin"] | ||
| id = "jackin:14746904" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_tags["jackin"] | ||
| id = "jackin:15179226" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository.managed_settings["jackin-agent-smith"] | ||
| id = "jackin-agent-smith" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_main["jackin-agent-smith"] | ||
| id = "jackin-agent-smith:14742580" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_tags["jackin-agent-smith"] | ||
| id = "jackin-agent-smith:15179228" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository.managed_settings["jackin-dev"] | ||
| id = "jackin-dev" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_main["jackin-dev"] | ||
| id = "jackin-dev:14742570" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_tags["jackin-dev"] | ||
| id = "jackin-dev:15179232" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository.managed_settings["jackin-github-terraform"] | ||
| id = "jackin-github-terraform" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_main["jackin-github-terraform"] | ||
| id = "jackin-github-terraform:15175310" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_tags["jackin-github-terraform"] | ||
| id = "jackin-github-terraform:15179227" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository.managed_settings["jackin-marketplace"] | ||
| id = "jackin-marketplace" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_main["jackin-marketplace"] | ||
| id = "jackin-marketplace:14742574" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_tags["jackin-marketplace"] | ||
| id = "jackin-marketplace:15179224" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository.managed_settings["jackin-role-action"] | ||
| id = "jackin-role-action" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_main["jackin-role-action"] | ||
| id = "jackin-role-action:15170996" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_tags["jackin-role-action"] | ||
| id = "jackin-role-action:16515394" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository.managed_settings["jackin-sentinel"] | ||
| id = "jackin-sentinel" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_main["jackin-sentinel"] | ||
| id = "jackin-sentinel:17461058" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_tags["jackin-sentinel"] | ||
| id = "jackin-sentinel:17461059" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository.managed_settings["jackin-the-architect"] | ||
| id = "jackin-the-architect" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_main["jackin-the-architect"] | ||
| id = "jackin-the-architect:14742576" | ||
| } | ||
|
|
||
| import { | ||
| to = module.repository_policy.github_repository_ruleset.protect_tags["jackin-the-architect"] | ||
| id = "jackin-the-architect:15179230" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # SPDX-FileCopyrightText: 2026 Alexey Zhokhov | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Canonical check-list templates. Terraform requires variable defaults to be | ||
| # literals, so inventory entries in variables.tf repeat these lists verbatim; | ||
| # keep both in sync. Templates are the documented copy-paste source for adding | ||
| # a repo (see README.md). | ||
| locals { | ||
| check_templates = { | ||
| standard = ["Required", "DCO"] | ||
| policy = ["Policy"] | ||
| } | ||
| } |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
repository_policiescontains an extra or misspelled key, this assertion only produces a warning because OpenTofucheckfailures do not stop planning or applying. The module subsequently iterates over that key and can create or manage an unintended GitHub repository despite the message claiming that exactly nine repositories are allowed; enforce this through variable validation or a resource/module precondition instead.Useful? React with 👍 / 👎.