55 lines
2.8 KiB
Markdown
55 lines
2.8 KiB
Markdown
# 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) and `modules/repository` (repo, default branch, collaborators, CODEOWNERS, rulesets via `modules/ruleset`).
|
|
|
|
`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`:
|
|
|
|
```yaml
|
|
description: "IUCLabs maintainers"
|
|
privacy: closed
|
|
maintainers: [neoloc]
|
|
members: []
|
|
```
|
|
|
|
`repository/<name>.yaml` (every field, with defaults):
|
|
|
|
```yaml
|
|
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
|
|
branch_protection: !private # generated `branch-protection` ruleset on the default branch
|
|
tag_protection: !private # generated `tag-protection` ruleset: refs/tags/v* undeletable, immutable
|
|
required_checks: [] # generated `required-checks` ruleset (strict)
|
|
rulesets: [] # custom rulesets from ruleset/
|
|
```
|
|
|
|
Public repositories always get generated `ref-names-branch` and `ref-names-tag` rulesets blocking creation of refs with a `+` path component, which would act as a wildcard in Vault policy paths templated from the GitHub OIDC `ref` claim.
|
|
|
|
`ruleset/<name>.yaml` (custom extras; `branch-protection`, `required-checks`, `tag-protection`, `ref-names-branch` and `ref-names-tag` are reserved):
|
|
|
|
```yaml
|
|
target: branch
|
|
enforcement: active
|
|
conditions:
|
|
ref_name:
|
|
include: ["refs/heads/release/*"]
|
|
exclude: []
|
|
rules:
|
|
deletion: true
|
|
non_fast_forward: true
|
|
```
|
|
|
|
Private repositories cannot use `branch_protection`, `tag_protection`, `required_checks` or `rulesets` on the free plan; plan fails if they do.
|