Example repository for mirroring from github to gitlab using webhooks and pipeline triggers.
- create a project scoped access token with maintainer role and
write_repository, api
flags - create a project scoped ci variable named
ACCESS_TOKEN
and store the access token within - create a pipeline trigger token
- add the following job to your
.gitlab-ci.yml
:mirror_repository: image: alpine variables: SRC_ORIGIN: https://github.com/path-to-your-repository DEST_ORIGIN: https://oauth2:[email protected]/path-to-your-repository stage: mirror only: - triggers before_script: - apk add git - git config user.name ci-bot - git config user.email "[email protected]" script: - git clone $SRC_ORIGIN gh-mirror - cd gh-mirror - git remote remove origin - git remote add origin $DEST_ORIGIN - git push --prune --all - git push --prune --tags
- create a webhook for push event and insert the pipeline trigger url as payload url