sixtyfootersdude
sixtyfootersdude

Reputation: 27231

How to store github settings as code instead of in a UI

Is there a way to store my github repo's settings "as-code" rather than interacting with the settings via UI? Aka these things:

enter image description here

I would like to do this so that:

  1. We can keep a history of changes
  2. Changes can be PR reviewed

Right now our team has several admins and people frequently update settings. This makes it hard to understand why settings are setup a certain way. This is paticularly an issue with branch protection rules:

enter image description here

I would like some way to store all of these settings in a text file, either in YAML or Terraform or something else. Is this possible?

Upvotes: 0

Views: 80

Answers (1)

scorpp
scorpp

Reputation: 668

There are mainly 3 options that I've found. I haven't tried either of them myself yet though.

  1. https://github.com/github/safe-settings

    an app to manage policy-as-code and apply repository settings across an organization.

  2. Custom script with GH CLI similar to https://github.com/adamchainz/scripts/blob/main/myrepos/0000-repo-settings.sh

  3. Terraform https://registry.terraform.io/providers/integrations/github/latest/docs

P.S. .github/ (even euphemeral) approach doesn't seem adequate as it would allow anybody having commit access to update repo settings, which effectively hijacks GH permissions model.

Upvotes: 1

Related Questions