.NET code to create and configure a repo with C#. I'm in GitHub everyday. There are certain activities I found myself manually doing on a regular basis. Not super long activities, but boring, repetitive activities - the types of activities that are perfect for automation. Hence this project:
- Enables repo "auto-merge" open
- Enables repo "Delete head branch on merge" option
- Enables repo visibility to be set
- Creates the initial project.
- Clone the project to a folder (
Target folder) https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository - Create src folder
- Creates .NET test project (
test project nameandtest project type) https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-new - Creates .NET console\library\webapi\web app project (
project nameandproject type) https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-new - Creates .NET solution (
solution name) https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-sln
- Clone the project to a folder (
- Creates the GitHub action to build/test/publish the .NET projects added above
- Adds an action status badge to the readme file
- Creates the dependabot configuration
- Push all of the changes back to the repository/GitHub
- Sets up branch policies on default branch (e.g. require a pull request and successful build action)
RepoAutomation [-o|--owner <GITHUB-OWNER/ACCOUNT>]
[-r|--repo <REPOSITORY-NAME>]
[-d|--directory <WORKING-DIRECTORY>]
[-v|--visibility <REPO-VISIBILITY>]
[-p|--projectTypes <.NET-COMMA-DELIMITED-PROJECTS]Requires a Fine-Grained PAT token to be setup, with:
- Actions: Read-only (can view workflows and actions, but cannot modify or trigger them)
- Administration: Read and write (can view and perform admin tasks on repositories)
- Code scanning alerts: Read-only (can view code scanning alerts, but cannot resolve or dismiss them)
- Contents: Read (can view repository contents, but cannot modify them)
- Dependabot alerts: Read (can view Dependabot alerts)
- Deployments: Read (can view deployment statuses)
- Metadata: Read (can view repository metadata)
- Pull Requests: Read and write (can view, create, update, and merge pull requests)
- Repository security advisories: Read (can view security advisories for repos)
- Secret Scanning alerts: Read (can view secret scanning alerts)
Using default settings to create a new repository "RepoAutomationTest", with a .NET 6 class library and unit tests project:
RepoAutomation --owner samsmithnz --repo RepoAutomationTest --directory c:\users\sam\source\repos --visibility public --projectTypes classlib,mstest
For governance, we are building a website to monitor repos and take corrective action:


