GH Mass-administration: Content

This is a part of my guide to how I manage multiple Github repositories. This post focuses on streamlining content in those repositories, such that they all use the same Github workflows, have common build properties set and so on. Back to main guide.

Declaring sets of files

For my use case, I want to have a set of common files that are shared amongst all repositories with .NET projects (nuget packages / tools), docker projects (Dockerfiles, sharing on Docker Hub) or just plain repositories.

I've declared a few sets:

  • standardContent: Default files for all repos, like .gitignore. My git ignore will be very generic, but will have to cover all cases, as we can't inherit git ignores :/.
  • standardDotnetNuget: Default workflows and Directory.Build.Props for .NET projects that can build nuget packages. The props contain common properties I want, like enabling latest C# language and putting myself as an author.
  • standardDocker: Default workflows for docker-based projects that push to Docker Hub. Also contains a docker ignore that skips folders like .git, bin/ and obj/.

All these sets are defined inside my repos.json file. If a repository should have the set, it is indicated by setting a property boolean to true:

  "content": {
    "standardContent": {
      ".gitignore": "standard_content\\.gitignore"
    "standardDocker": {
      ".github/workflows/docker-dev.yml": "standard_content\\docker-dev.yml",
  "repositories": {
    "LordMike/MBW.BlueRiiot2MQTT": {
      # Ensure this repository gets both .gitignore and docker workflows
      "standardContent": true,
      "standardDocker": true

Running gh-standard-content

I've built a tool that maintains pull requests on defined repositories, for files that should be managed. When run, it determines if files are up to date with the latest, and creates/updates a PR with any changes needed.

To use it, I've installed it locally in my configuration repository (which also houses my repos.json and other auxilliary files):

# Create a tool manifest for local tools
dotnet new tool-manifest

# Install gh-standard-content
dotnet tool install MBW.Tools.GhStandardContent

Once done, I've created a script that runs gh-standard-content. This script restores the tool if needed, and runs it.

# DoStandardContent.ps1
# Restore the local tools manifest
dotnet tool restore

# Run gh-standard-content locally
dotnet tool run gh-standard-content -t MY_GH_TOKEN repos.json
Michael Bisbjerg

Michael Bisbjerg