- Get GitLab admin user details
- Get GitLab sync user details
- Get GitHub admin user details
- Select source GitHub repo
- Either: Select/create destination GitLab repo
- Clone 1. add remote 2.
- Check branches on 1,2 are consistent/fast-forwardable (or 2 is empty)
- Enable builds on 2. select a builder.
- Generate a ssh keypair.
- Install private key to secret build variable on 2.
- Install public key to GitLab sync user.
- Grant GitLab sync user Developer permissions to 2.
- Create a trigger on 2.
- Update .gitlab-ci.yml with git sync CI task
- Commit and push repo to both.
- Install webhook for trigger on 1. (with GitHub trigger source variable)
In the above procedure, insert: After step 8:
- Install public key to GitHub repo as Deployment Key with write permissions.
- Push to GitHub
- GitHub webhook calls out to GitLab build trigger
- GitLab spawns build tasks including/not-excluding the "triggers" pattern.
- Git sync task executes (in GitHub mode).
- GitLab version of repository at some unspecified revision/branch is checked out automatically.
- Spawn ssh-agent with the stored private key.
- Add GitHub remote and fetch.
- Fast-forward each GitHub branch into the corresponding GitLab branch, creating if required.
- If any changes made, push to GitLab. (This build task ends).
- GitLab receives push and starts standard build process.
- GitLab executes GitLab->GitHub sync task as part of the standard build, it should be idempotent.
- Push to GitLab
- GitLab spawns build tasks.
- Git sync task executes (in GitLab mode).
- GitLab version of repository at some current revision/branch is checked out automatically.
- Spawn ssh-agent with the stored private key.
- Add GitHub remote and fetch.
- Fast-forward each GitLab branch into the corresponding GitHub branch, creating if required.
- If any changes made, push to GitHub. (This build task ends).
- GitHub receives push, triggers GitLab webhook, the resulting push should be idempotent.
- Force pushes on any repo will break the sync, good motivation to forbid them.
- All normal build tasks will need to be marked as excluding triggers, ones that need to be triggered need special handling, with build variables to select correct mode.