C#, .Net and Azure
The entire source-code can be found on Github.
Last year I wrote about how to automatically mirror git repositories.
Recently I started adding a lot more repositories (already created 12 this year) and I started to get annoyed by the remaining manual steps (create repository in every service, manually set up build to trigger mirroring on check-in) and so I decided to finally automate everything and improve the mirror process.
The result is an Azure Function that creates repositories in Gitlab/Azure DevOps and sets up Azure DevOps builds when new repositories are found in Github.
The actual git mirror task is then performed by build pipelines in Azure DevOps (triggered on every Github check-in).
The architecture is generic and consists of three major parts:
The Azure function runs on a schedule (every 5 minutes by default) and uses configuration files from a storage account to determine which accounts to monitor.
If new repositories are found, they are also created in all target accounts and finally a build is cloned that runs on every check-in of the new repository.
From then on the build will clone the repository (free of charges thanks to generous 1800 free Azure DevOps Pipeline minutes).
You can see it in action in my Azure DevOps account (each build prefixed with
[Github clone] is responsible for cloning the respective github repository to Azure DevOps & Gitlab).
Detailed setup instructions are available on Github.