DEV Community


Posted on • Originally published at

Sync Repos beetwen Github & Gitlab

I'm been using Gitlab since January 17, 2016 and I'm very happy with this tool for years was my main repository of code. But now I have some of repositories in Github and I want to sync them with Gitlab, because I want that Gitlab to be a source of truth

I research a little bit and I found this repo that show me how I can do it.

First, we need to look at process of sync:

Flow of sync

We need to start creating workflow file into your repo in Github, you can find the file in this link

name: GitlabSync

  - push
  - delete

    runs-on: ubuntu-latest
    name: Git Repo Sync
    - uses: actions/checkout@v3
        fetch-depth: 0
    - uses: wangchucheng/git-repo-sync@v0.1.0
        # Such as
        target-url: ${{ secrets.TARGET_URL }}
        # Such as wangchucheng
        target-username: ${{ secrets.TARGET_USERNAME }}
          # You can store token in your project's 'Setting > Secrets' and reference the name here. Such as ${{ secrets.ACCESS\_TOKEN }}
        target-token: ${{ secrets.TARGET_TOKEN }}
Enter fullscreen mode Exit fullscreen mode

As you can see we need to create 3 secrets to use this workflow:

Once you create the Token into Gitlab you need to add secrets into Github repository. To do these you need to go to Settings > Secrets and add the secrets.

These not it's the best way to do it, but it's a good way to start and simple way to do it and little maintenance.

Top comments (0)