On some GitLab servers the pull mirror option is not available.
It is possible to push from the GitHub side, though.
An example GitHub workflow is provided in .github/workflow/gitlab-sync.yml
.
In order for that to work, we need to:
- Create an access token on the GitLab repository (Settings->Access Tokens), with the
write_repository
scope. Select also theMaintainer
role for the token. - Set the secrets correctly:
- GITLAB_REPO: the url of the repository we want to push to
- GITLAB_USERNAME: the username of the owner of that repository
- GITLAB_REPO_TOKEN: The access token to the gitlab repository, obtained in the previous step.
- On the GitLab side, you might have to configure the branch rules
and the protected branches
(Settings->Repository),
to allow force push from
Maintainer
s - Trigger the workflow on GitHub either manually or by making a push on the right branch.
- This should cause the GitLab pipeline to run (on GitLab.com it might not run unless you have a runner assigned to your project, shared runners do not work).