Git mirror automation
Automate the mirroring of git repositories across multiple services (such as github, gitlab & Azure DevOps).
A long time ago I wrote about mirroring github, gitlab and Azure DevOps repositories.
I still use this workflow (with slight improvements) to mirror repositories but it still required a set of manual steps. I decided to automate them with this azure function.
Manual steps this project solves
While using the automation steps described in my blog post there are still manual steps left after creating a repository in github:
- Sign into and create the same repository in Gitlab
- Set the same description as github
- Sign into and create the same repository in Azure DevOps
- Create a new mirror build in Azure DevOps (by cloning an existing one and updating the source repository)
How it works
The azure function runs on a schedule and uses configuration files to scan the source for any new repositories.
If new repositories are found the function uses the APIs for Azure DevOps/Gitlab to create the necessary repository/build pipelines.
Once the build pipeline exists it is triggered on every push as well as a schedule to mirror the repository.
(I use Azure DevOps builds instead of github actions because Azure DevOps allows secret sharing across pipelines).
Overview & Supported features
Mirror repositories between Github, Gitlab & Azure DevOps using free Azure Pipelines for mirror automation!
The service has 3 major parts, all of them are executed as part of the Azure function once for every configuration file (loaded from storage):
- (1) Then function scans the source (by default every 5 minutes) for new repositories
- (2) For every new repository it creates a build that automatically mirrors the repository on any future changes (git push on any branch)
- (3) And finally it creates the target repositories (with identical names) at the desired target services
Examples can be found here.