Use AWS codecommit as a mirror for self hosted gitlab repo.
10K+
Use AWS codecommit as a mirror for self hosted gitlab repo. This could come in handy if you have your production linked with codecommit, or you just want to backup your branches of your self hosted gitlab to AWS.
Create a codecommit repo from AWS console. Find docs here.
Clone this repo.
git clone https://github.com/rtCamp/gitlab-aws-codecommit-mirror.git
docker build . -t <docker_hub_username>/gitlab-aws-codecommit-mirror
For example
docker build . -t rtcamp/gitlab-aws-codecommit-mirror
And push the newly built image to your Docker Hub Account.
Or you can use our image at rtcamp/gitlab-aws-codecommit-mirror
Register a new Gitlab CI runner with this docker image.
Clone your existing gitlab repo
Copy .gitlab-ci.yml from this repo to your repo.
If you want to sync to a ssh enabled AWS Codecommit repo, use the following variant .gitlab-ci.yml
image: rtcamp/gitlab-aws-codecommit-mirror
stages:
- deploy
deploy to production:
tags:
- codecommit
stage: deploy
script:
- bash setup_ssh
- git clone --mirror $SOURCE_REPO rtSync
- cd rtSync
- git branch -a
- git push --mirror $SCHEME://$REPO_URL
If you want to sync to a https enabled AWS Codecommit repo, use the following variant .gitlab-ci.yml
image: rtcamp/gitlab-aws-codecommit-mirror
stages:
- deploy
deploy to production:
tags:
- codecommit
stage: deploy
script:
- git clone --mirror $SOURCE_REPO rtSync
- cd rtSync
- git branch -a
- git push --mirror $SCHEME://$USERNAME:$SECRET@$REPO_URL
codecommit to tag of your newly created Gitlab CI Runner.SCHEME Either 'https' or 'ssh' (without quotes)
REPO_URL url of the AWS Code commit.(git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo)
SOURCE_REPO url of the source repo, it can be found on the project page of the Gitlab repo(Use ssh url of the repo).
https authentication for AWS Codecommit add the following variables.USERNAME AWS codecommit username
SECRET AWS codecommit password
ssh authentication for AWS Codecommit, add the following variable.SSH_PRIVATE_KEY Private key file content that is authenticated for AWS Codecommit.
ssh authentication. add setup_ssh file from this repo to your Gitlab repo.
.gitlab-ci.yml and other required files to see Gitlab CI Runner send the commits to AWS codecommit repo.docker pull rtcamp/gitlab-aws-codecommit-mirror:latest