janosh / auto-repo-config

Runs periodic GitHub Actions to change settings on your repos if they differ from .repo-config.yaml.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auto Repo Settings

Scheduled Workflow pre-commit.ci status

Inspired by asottile/set-delete-branch-on-merge.

GitHub does not provide a way to change the default settings for new repositories.

This tool runs a periodic GitHub Action to change settings on your repos if they differ from those specified in .repo-config.yaml.

Usage

  1. Fork this repository

  2. Create a personal access token (PAT) with scopes repo and/or admin:org depending on if you want to manage your own and/or organizational repos. If you're not sure, just set both.

  3. Create a repository secret under Settings > Secrets > New repository secret named GH_TOKEN and paste in your PAT. If you cloned the repo and want to run the action locally (e.g. for testing), also paste that token into a file gh_token.py:

    echo 'GH_TOKEN = "<your_token>"' > gh_token.py
  4. Modify the settings in .repo-config.yaml to your liking. Consult these docs for the GraphQL names of repo settings and these docs for the REST names of repo settings. Both names are necessary at the moment since the GraphQL API is more efficient at fetching only the relevant current settings of your repos but does not yet offer a mutation to update these settings. This requires a call to the REST API.

  5. Wait for the action to trigger automatically every Sunday at 10:00 UTC (can be configured in .github/workflows/schedule.yml by changing on.schedule.cron). You can also trigger it manually by going to the Actions tab and clicking the "Run workflow" button.

  6. Enjoy! No more repetitive, manual repo configuration.

Files of Interest

GraphiQL Explorer

To get acquainted with the GitHub GraphQL API, check out this live interface with autocomplete and docs. For example, try running

{
  viewer {
    repositories(first: 100) {
      nodes {
        name
      }
    }
  }
}

to see a list of your repos.

About

Runs periodic GitHub Actions to change settings on your repos if they differ from .repo-config.yaml.

License:MIT License


Languages

Language:Python 100.0%