Import GitHub repository Collaborators as GitLab project members
Release notes
Until now, when importing projects from GitHub to GitLab, repository collaborators were not imported. That resulted in no users having any permissions on a project created in Gitlab. To work around it, we added users to the GitLab parent group. Now we are adding all GitHub repository collaborators (that can be mapped to GitLab users) as GitLab project members. The mapping of the roles is as follows:
- GH Read - GL Guest
- GH Triage - GL Reporter
- GH Write - GL Developer
- GH Maintain - GL Maintainer
- GH Admin - GL Owner.
Using GitHub Enterprise Cloud there is possibility to create custom repository roles. As these roles must be inherited from one of basic roles (Read, Triage, Write, Maintain), we map them to GitLab roles based on the role they inherited from.
Problem to solve
When migrating projects from GitHub to GitLab, no project collaborators are imported. This means that, after the migration, no user will have any permissions on a project. To work around it, at the moment we add users to the parent group in GitLab to successfully import some branch protection rules (see Branch protection rules and project settings).
Proposed solution
During project import from GitHub, add all the GitHub collaborators as GitLab project members.
Note: only GitHub users that can be mapped to GitLab users would be added as project members.
Based on GH doc, there are 5 roles for users that have access to a repository:
- Read
- Triage
- Write (this role has collaborator of a repository owned by a personal account)
- Maintain
- Admin (this role has owner for a repository owned by a personal account)
We want to map these roles to GitLab roles for users who are members of a project:
- GH Read - GL Guest
- GH Triage - GL Reporter
- GH Write - GL Developer
- GH Maintain - GL Maintainer
- GH Admin - GL Owner
Note: Using GitHub Enterprise Cloud there is possibility to create custom repository roles. As these roles must be inherited from one of basic roles (read, triage, write, maintain), we will map them to GitLab roles based on inherited role.
Related GitHub docs.
GitHub documentation pages related to permissions to repositories:
Documentation
It will no longer be necessary to add any users to the parent group in GitLab to successfully import some branch protection rules (see Branch protection rules and project settings). That should be documented.
Following documentation should be updated with the changes implemented in this issue:
-
📖 User doc: https://docs.gitlab.com/ee/user/project/import/github.html -
📖 Developer doc: https://docs.gitlab.com/ee/development/github_importer.html
Technical details
According to the GitHub API documentation:
- we can use
GET
/repos/{owner}/{repo}/collaborators to get a list of collaborators for a project
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.