manage IUCLabs GitHub organisation #118

Merged
benvin merged 9 commits from benvin/github-iuclabs into main 2026-11-10 22:49:21 +11:00
Member

The IUCLabs GitHub organisation needs the same declarative YAML management as Gitea, without Gitea runs needing GitHub creds.

  • add modules/github_org: validates config, calls team and repository submodules
  • repository owns the repo, default branch, collaborators, CODEOWNERS and rulesets (via ruleset)
  • derive merge settings and generated rulesets from repo flags; ruleset/ adds custom ones
  • rename the auto-init main to default_branch
  • reject protected private repos (free plan), reserved/unknown rulesets, unknown teams, invalid shapes
  • add environments/github/iuclabs; GitHub App creds from Vault in a subshell
  • run Gitea and GitHub units separately in make plan/apply/apply-if-changes
  • split config/github.com/ out of Gitea inputs; add make test to pre-commit
The IUCLabs GitHub organisation needs the same declarative YAML management as Gitea, without Gitea runs needing GitHub creds. - add `modules/github_org`: validates config, calls `team` and `repository` submodules - `repository` owns the repo, default branch, collaborators, CODEOWNERS and rulesets (via `ruleset`) - derive merge settings and generated rulesets from repo flags; `ruleset/` adds custom ones - rename the auto-init `main` to `default_branch` - reject protected private repos (free plan), reserved/unknown rulesets, unknown teams, invalid shapes - add `environments/github/iuclabs`; GitHub App creds from Vault in a subshell - run Gitea and GitHub units separately in `make plan/apply/apply-if-changes` - split `config/github.com/` out of Gitea inputs; add `make test` to pre-commit
unkin-agent added 1 commit 2026-11-09 23:54:05 +11:00
manage IUCLabs GitHub organisation
ci/woodpecker/pr/plan Pipeline failed
ci/woodpecker/pr/pre-commit Pipeline was successful
e7eee508d7
Author
Member
  • Makefile:17-20 — vault_env reads kv/service/github/iuclabs/terraform for every target, so an unreadable secret (terraform-vault PR not applied) aborts plan/apply for au/syd1 Gitea too; ci/woodpecker/pr/plan is red at the plan step → export GITHUB_* only when running the github unit (or split into a separate target/step), and keep Gitea plan independent of the GitHub secret.
  • Makefile:plan/apply — terragrunt run --all now includes environments/github/iuclabs, so a GitHub-side failure blocks Gitea applies → merge only after the terraform-vault PR is applied and plan is green, or exclude the github unit from the Gitea run.
  • nit: modules/github_org/main.tf:62-72,89 — team slug is taken from the YAML key (team.key, trimprefix(e, "@")), which breaks for names with caps/spaces → use github_team.this[...].slug.
  • nit: modules/github_org/main.tf:79 — github_repository_file.codeowners fails on auto_init = false repos (no branch to commit to) → validate auto_init when maintainers is set, or skip the file.
- Makefile:17-20 — vault_env reads kv/service/github/iuclabs/terraform for every target, so an unreadable secret (terraform-vault PR not applied) aborts plan/apply for au/syd1 Gitea too; ci/woodpecker/pr/plan is red at the `plan` step → export GITHUB_* only when running the github unit (or split into a separate target/step), and keep Gitea plan independent of the GitHub secret. - Makefile:plan/apply — `terragrunt run --all` now includes environments/github/iuclabs, so a GitHub-side failure blocks Gitea applies → merge only after the terraform-vault PR is applied and plan is green, or exclude the github unit from the Gitea run. - nit: modules/github_org/main.tf:62-72,89 — team slug is taken from the YAML key (`team.key`, `trimprefix(e, "@")`), which breaks for names with caps/spaces → use `github_team.this[...].slug`. - nit: modules/github_org/main.tf:79 — `github_repository_file.codeowners` fails on `auto_init = false` repos (no branch to commit to) → validate `auto_init` when `maintainers` is set, or skip the file.
unkin-agent added 1 commit 2026-11-09 23:58:51 +11:00
scope GitHub App secret to the github unit, use team slugs
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline failed
691eca53ea
Author
Member
  • environments/github/iuclabs/terragrunt.hcl:23-25 — run_cmd vault calls are evaluated at parse time, and the Makefile runs terragrunt run --all for init/plan/apply, so a vault failure or missing read policy on kv/service/github/iuclabs/terraform aborts the whole run including au/syd1 → fetch the secrets outside HCL (Makefile github-only target exporting GITHUB_APP_*) so au/syd1 has no dependency on it, or exclude the github unit from the Gitea targets.
  • environments/github/iuclabs/terragrunt.hcl:23-25 — resolved PEM/app id are stored in terraform.extra_arguments.env_vars, so terragrunt render --json (and any config dump) prints the PEM → keep the secret out of terragrunt config; same fix as above.
  • nit: environments/au/syd1/terragrunt.hcl:19 — inputs and state path are identical, but providers now generate to provider.tf and backend.tf shrinks, so the generated files differ from main → acceptable only if intended; otherwise keep them in backend.tf.
  • nit: modules/github_org/main.tf:40 — removing a repository yaml destroys the GitHub repo and its contents → set archive_on_destroy = true.
  • nit: modules/github_org/variables.tf:74 — an unknown name in rulesets fails at var.ruleset[rs] with an opaque index error → add a validation that every rulesets entry exists in var.ruleset.
- environments/github/iuclabs/terragrunt.hcl:23-25 — `run_cmd` vault calls are evaluated at parse time, and the Makefile runs `terragrunt run --all` for init/plan/apply, so a vault failure or missing read policy on `kv/service/github/iuclabs/terraform` aborts the whole run including au/syd1 → fetch the secrets outside HCL (Makefile github-only target exporting `GITHUB_APP_*`) so au/syd1 has no dependency on it, or exclude the github unit from the Gitea targets. - environments/github/iuclabs/terragrunt.hcl:23-25 — resolved PEM/app id are stored in `terraform.extra_arguments.env_vars`, so `terragrunt render --json` (and any config dump) prints the PEM → keep the secret out of terragrunt config; same fix as above. - nit: environments/au/syd1/terragrunt.hcl:19 — inputs and state path are identical, but providers now generate to `provider.tf` and `backend.tf` shrinks, so the generated files differ from main → acceptable only if intended; otherwise keep them in `backend.tf`. - nit: modules/github_org/main.tf:40 — removing a repository yaml destroys the GitHub repo and its contents → set `archive_on_destroy = true`. - nit: modules/github_org/variables.tf:74 — an unknown name in `rulesets` fails at `var.ruleset[rs]` with an opaque index error → add a validation that every `rulesets` entry exists in `var.ruleset`.
unkin-agent added 2 commits 2026-11-10 00:05:44 +11:00
Author
Member

No findings.

No findings.
unkin-agent added 1 commit 2026-11-10 21:52:59 +11:00
generate github rulesets from repo flags, trim repo schema
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
132e93c0d4
unkin-agent added 1 commit 2026-11-10 21:56:51 +11:00
generate tag-protection ruleset for release tags
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
d7359d1fc7
Author
Member
  • modules/github_org/main.tf:121 — github_branch_default with default_branch != main fails apply: auto_init only creates main and rename is not set → set rename = true (or validate default_branch == "main").
  • nit: modules/github_org/variables.tf:252 — custom ruleset with target = "tag" plus pull_request/required_status_checks, or required_status_checks.contexts = [], passes plan but GitHub rejects it (422) at apply → add a validation for both cases.
- modules/github_org/main.tf:121 — `github_branch_default` with `default_branch` != `main` fails apply: `auto_init` only creates `main` and `rename` is not set → set `rename = true` (or validate default_branch == "main"). - nit: modules/github_org/variables.tf:252 — custom ruleset with `target = "tag"` plus `pull_request`/`required_status_checks`, or `required_status_checks.contexts = []`, passes plan but GitHub rejects it (422) at apply → add a validation for both cases.
unkin-agent added 1 commit 2026-11-10 22:01:38 +11:00
rename auto-init main to default_branch and reject invalid ruleset shapes
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
23c315a49a
Author
Member

No findings.

No findings.
unkin-agent added 1 commit 2026-11-10 22:32:32 +11:00
split github_org into team, repository and ruleset submodules
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
d6d608b2a1
Author
Member
  • modules/github_org/main.tf:20 — a @team in maintainers/codeowners that is not a key of var.team fails with an opaque "Invalid index" on module.team[...] → add a repository validation in variables.tf listing unknown teams (as done for rulesets) plus a expect_failures test.
  • nit: modules/github_org/modules/team/outputs.tf:1 — id output is consumed nowhere → drop it.
- modules/github_org/main.tf:20 — a `@team` in `maintainers`/`codeowners` that is not a key of `var.team` fails with an opaque "Invalid index" on `module.team[...]` → add a `repository` validation in variables.tf listing unknown teams (as done for rulesets) plus a `expect_failures` test. - nit: modules/github_org/modules/team/outputs.tf:1 — `id` output is consumed nowhere → drop it.
unkin-agent added 1 commit 2026-11-10 22:41:13 +11:00
reject repository references to undefined teams
ci/woodpecker/pr/plan Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
e62c3246ea
Author
Member

No findings.

No findings.
benvin merged commit 254747e5ac into main 2026-11-10 22:49:21 +11:00
benvin deleted branch benvin/github-iuclabs 2026-11-10 22:49:22 +11:00
This repo is archived. You cannot comment on pull requests.