This repository has been archived on 2026-11-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
unkin-agent 5a786be0e6
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
Define all GitHub rulesets as ruleset/ files
2026-11-14 19:25:07 +11:00
2026-06-10 23:45:41 +10:00

terraform-git

Manage Gitea resources, teams, repos, and Woodpecker CI via Terraform.

GitHub (IUCLabs)

config/github.com/IUCLabs/ feeds modules/github_org via environments/github/iuclabs, authenticated as a GitHub App (kv/service/github/iuclabs/terraform). Org membership invites are manual.

modules/github_org validates config, manages org-level settings, and calls modules/team (team + memberships), modules/repository (repo, default branch, collaborators, CODEOWNERS) and modules/ruleset once per effective <repo>/<ruleset> pair, after the repositories.

config.yaml (optional) manages org settings: profile (name, description, blog, location, email, twitter_username, company), default_repository_permission (read, or none), members_can_create_repositories (false), public_runners (false; lets public repos use the Default runner group). Every other org setting is pinned in the module (no Pages, no repo projects, legacy security toggles off), and GITHUB_TOKEN is read-only and non-approving. billing_email comes from the billing_email field of the same Vault path (TF_VAR_billing_email). These resources are prevent_destroy, so deleting config.yaml fails the plan; to stop managing them, add removed { from = <resource>; lifecycle { destroy = false } } blocks to modules/github_org.

team/<name>.yaml:

description: "IUCLabs maintainers"
privacy: closed
maintainers: [neoloc]
members: []

repository/<name>.yaml (every field, with defaults):

description: ""
private: true
default_branch: main
maintainers: []            # users or @team: maintain access, seed initial .github/CODEOWNERS
codeowners: []             # push access, for adding to CODEOWNERS later
merge_type: squash         # squash | merge | rebase
delete_branch_on_merge: true
rulesets: []               # opt-in rulesets from ruleset/ (public repos only)
exclude_rulesets: []       # opt out of non-mandatory all_repos rulesets

ruleset/<name>.yaml defines every ruleset:

all_repos: false   # apply to every public repo (private repos are skipped)
mandatory: false   # cannot be listed in exclude_rulesets
target: branch     # branch | tag
enforcement: active
conditions:
  ref_name:
    include: ["refs/heads/release/*"]
    exclude: []
rules:
  creation: false
  deletion: true
  non_fast_forward: true

branch-protection (PRs on the default branch) and tag-protection (refs/tags/v* undeletable, immutable) apply to all public repos. ref-names-branch and ref-names-tag are mandatory: they block refs with a + path component, which would act as a wildcard in Vault policy paths templated from the GitHub OIDC ref claim.

Required status checks are a custom ruleset referenced via rulesets:, e.g. rules: {required_status_checks: {contexts: [ci/woodpecker], strict: true}}.

Private repositories cannot list rulesets on the free plan; plan fails if they do. Unknown names, excluding a mandatory ruleset, or listing a ruleset in both lists also fail.

S
Description
Manage Gitea and GitHub resources, teams, and repos via Terraform
Readme 1 MiB
Languages
HCL 95.2%
Makefile 4.8%