Auto Repo Settings
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
-
Fork this repository
-
Create a personal access token (PAT) with scopes
repo
and/oradmin:org
depending on if you want to manage your own and/or organizational repos. If you're not sure, just set both. -
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 filegh_token.py
:echo 'GH_TOKEN = "<your_token>"' > gh_token.py
-
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. -
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. -
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.