Skip to content

Declarative GitHub infrastructure

Manage repository settings, labels, rulesets and files in YAML. Review the changes with plan, then apply exactly those. No state file, no HCL.

$ gh extension install babarot/gh-infra
repos/my-project.yaml
spec:
  visibility: public
  features:
    wiki: false    discussions: true  topics: [go, cli]
gh infra plan ./repos/
  ~ babarot/my-project  3 to update
      ~ features.wiki         true  → false
      ~ features.discussions  false → true
      ~ topics                [] → [go, cli]

From an existing repository to YAML you review

Start from what is on GitHub today. Every later change goes through a plan.

  1. Import

    get the current settings
    gh infra import
    $ gh infra import babarot/my-project \
        > repos/my-project.yaml
    
    apiVersion: gh-infra/v1
    kind: Repository
    ...
  2. Plan

    edit the YAML, see the diff
    gh infra plan
      ~ babarot/my-project
          ~ features.wiki  true → false
          ~ topics  [] → [go, cli]
    
    Plan: ~ 2 to update
  3. Apply

    make exactly those changes
    gh infra apply
    ✓ babarot/my-project  2 applied
    
    $ gh infra plan ./repos/
    No changes. Infrastructure is up-to-date.

Built for plan-only review

A pull request shows the plan, and merging it runs apply. Nobody watches the apply, so three rules keep the plan honest.

apply does what plan shows

Every change apply makes is in the plan, and apply makes no other change.

What you leave out is left alone

A field that is not in the manifest is not compared and not sent.

One apply converges

After apply, the next plan shows no changes.

Read the design principles