Skip to content

Getting Started

  • gh CLI installed and authenticated (gh auth login)
  • Repositories you want to manage must be accessible with your current gh token
Terminal window
gh extension install babarot/gh-infra

Recommended. Installs as a gh subcommand — run gh infra plan, gh infra apply, etc. Authentication is shared with gh auth, so no additional token setup is needed.

Verify the installation:

Terminal window
gh infra --help
  1. Import an existing repository

    Start by exporting a repository’s current settings to YAML:

    Terminal window
    gh infra import babarot/my-project > repos/my-project.yaml

    This generates a complete YAML manifest reflecting the repository’s current state on GitHub.

  2. Edit the YAML

    Open the file and change what you want. For example, enable discussions, disable wiki, and add topics:

    apiVersion: gh-infra/v1
    kind: Repository
    metadata:
    name: my-project
    owner: babarot
    spec:
    description: "My awesome project"
    visibility: public
    topics:
    - go
    - cli
    features:
    issues: true
    projects: false
    wiki: false
    discussions: true
  3. Preview changes

    Run plan to see what would change without making any modifications:

    Terminal window
    gh infra plan ./repos/
    Plan: 0 to create, 1 to update, 0 to destroy
    ~ babarot/my-project
    ~ features.wiki: true => false
    ~ features.discussions: false => true
    + topics: [go, cli]
  4. Apply

    When you’re happy with the plan, apply:

    Terminal window
    gh infra apply ./repos/

    gh-infra will show the plan again and ask for confirmation before making changes.

gh-infra demo gh-infra demo

gh-infra supports four resource kinds:

KindWhat it does
RepositoryManage a single repo’s settings
RepositorySetManage many repos with shared defaults
FileManage files in a single repo
FileSetDistribute files (LICENSE, CODEOWNERS, workflows) across repos

See the Resources for the full specification, or check out the Guides for different usage patterns.