/Contributions-Importer-From-Gitlab

This tool helps users to import contributions continuously via GitLab API without cloning.

Primary LanguagePythonMIT LicenseMIT

Contributions Importer from GitLab

This tool based on Miro Mannino's Contributions Importer for GitHub and helps users to import contributions continuously via GitLab API without cloning.

2022_alpha_light_gitlab 2022_alpha_dark_gitlab

2022_alpha_light_github 2022_alpha_dark_github

How it Works

Login to GitHub with your personal access token to get your username, primary email and clone the mock repository. Read the last mock commit date to count from. After that, authorize with a personal access token for each GitLab server to get a list of projects with developer permissions changed since our date via the API. Requests all user commits since our date for each project and sort them by date for backwards compatibility. Then parse each commit to get a list of changed file types with insertion and deletion counts. At the end, this data is sent to the original importer to create new mock commits. All changes are pushed to GitHub before exit.

How to Use

First of all, you need to create a personal access token for GitHub. Go to Settings -> Developer settings -> Personal access tokens -> Tokens (classic) -> Generate new token (classic), or just use the direct link. You need to give access to user:email and repo for full control of private mock repository. Don't set an expiration date, if you won't to update the token.

Similarly create personal access tokens for each your GitLab servers. Go to Preferences -> Access Tokens. Give read_api access.

alpha_light_token alpha_dark_token

Create a mock repository named gitlab-contributions in your account. Strongly recommended to use a private repository. Then fork this repository and set up GitHub Secrets. Go to repository Settings -> Security -> Secrets -> Actions -> New repository secret:

  • ACCESS_TOKEN – your Github personal access token
  • GITLAB_SERVER_URL – line-separated list of your GitLab servers, including protocol and port
  • GITLAB_TOKEN – line-separated list of your GitLab API access tokens

alpha_light_secrets alpha_dark_secrets

The final step is to enable the GitHub Actions workflow. Go to Actions tab and click I understand my workflows, go ahead and enable them. Select the GitLab Contributions workflow and enable it. The synchronization task will be automatically scheduled at 00:00 UTC.

alpha_light_workflow alpha_dark_workflow

P.s. You should set up all your GitLab servers at once to prevent your old commits missing!
P.p.s. You can override the default mock repository name by setting the REPOSITORY_NAME secret.