The number of Github repositories that I end up maintaining in one way or another ends up growing week by week. And keeping all of the descriptions and settings up to date in sync can be painful todo by hand.

A little while ago I migrated my addwiki project to use a monorepo, and thus needed to bulk update all of the github repository descriptions. While doing so I made use of the github cli and created a single bash script to let me configure all of the repositories at once.

Assuming you already have the github cli install and configured getting started with this is easy.

The command

The below command is one of many in my bash script for repo configuration. This sets a description, homepage and various other flags that I want to be consistent across repositories.

gh api --method PATCH repos/addwiki/addwiki \ --field description='Monorepo containing all addwiki libraries, packages and applications'\ --field homepage='https://addwiki.github.io/'\ --field has_issues='true'\ --field has_projects='false'\ --field has_wiki='false'
Code language: JavaScript (javascript)

Multiple of these such commands can be combined into a single file to allow easy editing and syncing. Personally I have put this script in my monorepo .github directory. https://github.com/addwiki/addwiki/blob/main/.github/bin/sync-repos

An upgrade

An upgrade to this approach could generate the commands from a JSON file rather than needing to copy and paste the github cli command over and over again.

For my example this could look something like this:

{ "addwiki/addwiki":{ "description": "Monorepo containing all addwiki libraries, packages and applications", "homepage": "https://addwiki.github.io/", "has_issues": true, "has_projects": false, "has_wiki": false } }
Code language: JSON / JSON with Comments (json)

If I ever upgrade my script I’ll be sure to link the new version to this post.

Possible alternative

At least one Github action now exists covering general Github repository setting, but seemingly not descriptions, which were part of my main use.

The Repo Setting Sync action allows settings such as ALLOW_WIKI or BRANCH_PROTECTION_NAME uniformly across a a collection of repositories with little effort.

- name: Repo Setup uses: kbrashears5/github-action-repo-settings-sync@v1.0.0 with: REPOSITORIES: | addwiki/addwiki ALLOW_ISSUES: 'true' ALLOW_PROJECTS: 'false' ALLOW_WIKI: 'false' TOKEN: ${{ secrets.ACTIONS }}
Code language: JavaScript (javascript)

If this action allows setting things such as description or homepage it would be pretty easy to setup a matrix within an action to set slightly modified settings, such as descriptions per repository.