For GitLab, pull/push mirror has to be set up for each repository manually.
I want to know is there any way that could automatically sync all Github repo to GitLab, such that
- when you create a new repo in GitHub, a repo in GitLab will be automatically be created and act like a pull mirror.
- for all old repo in Github, set up repos in GitLab that will act like pull mirrors.
below is what I have thought:
- proposal:
- doesnt use gitlab pull mirror or github action to push
- approach 0: a script in a server periodically pulling the change from all github repo to local from github and pushing to gitlab.
- problems
- required the server to be always running, and it has to contains all the github repos in drive.
- problems
- approach 0: a script in a server periodically pulling the change from all github repo to local from github and pushing to gitlab.
- use gitlab pull mirror:
- approach 1: when you create a new repo in GitHub, the webhook is sent to a script that could create a GitLab repo, and then setup the mirror
- problems
- there is no API to configure the pull mirror in gitlab, so it couldn't be automated. existing feature request
- even there are api, pull mirror only support password or deploy key
- password: your github account become dangerous
- deploy key:
- have to retrieve the deploy key by program
- seems no easy way of automatically attaching the deploy key to github repo by api ?
- problems
- approach 1: when you create a new repo in GitHub, the webhook is sent to a script that could create a GitLab repo, and then setup the mirror
- use github action to act like a push mirror:
- approach 2: a server constantly running to check if any GitHub repo doesnt has a counter part in Gitlab, if found, create a GitLab repo, add a gitHub action by api to that GitHub repository that is set to push the change to the newly created gitlab repo.
- advantage:
- all old repository and new repository in Github will be linked to gitlab.
- problems:
- since the server has to add a github action, it means that it has write permission to all github repository, if the server is hacked, hacker could add any commit or change commit history.
- the github action will have write permission to counterpart gitlab repository
- possibly by ssh key set in github secret
- so the secret has to be added by api also, but seems such api doesnt exist yet github secret api
- possibly by ssh key set in github secret
- advantage:
- approach 2: a server constantly running to check if any GitHub repo doesnt has a counter part in Gitlab, if found, create a GitLab repo, add a gitHub action by api to that GitHub repository that is set to push the change to the newly created gitlab repo.
- doesnt use gitlab pull mirror or github action to push