debian-mirror-gitlab/doc/administration/raketasks/github_import.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
2.2 KiB
Markdown
Raw Normal View History

2021-01-29 00:20:46 +05:30
---
2022-07-23 23:45:48 +05:30
stage: Systems
2021-02-22 17:27:13 +05:30
group: Distribution
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2021-01-29 00:20:46 +05:30
---
2023-03-04 22:38:38 +05:30
# GitHub import Rake task **(FREE SELF)**
2017-08-17 22:00:37 +05:30
2023-04-23 21:23:45 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/390690) in GitLab 15.9, Rake task no longer automatically creates namespaces or groups that don't exist.
2021-01-03 14:25:43 +05:30
To retrieve and import GitHub repositories, you need a [GitHub personal access token](https://github.com/settings/tokens).
A username should be passed as the second argument to the Rake task,
2021-02-22 17:27:13 +05:30
which becomes the owner of the project. You can resume an import
2018-12-13 13:39:08 +05:30
with the same command.
2022-08-13 15:12:31 +05:30
Bear in mind that the syntax is very specific. Remove any spaces in the argument block and
2022-07-23 23:45:48 +05:30
before/after the brackets. Also, some shells (for example, Zsh) can interpret the open/close brackets
2022-08-13 15:12:31 +05:30
(`[]`) separately. You may want to either escape the brackets or use double quotes.
2018-12-13 13:39:08 +05:30
2023-03-17 16:20:25 +05:30
Prerequisite:
- At least the Maintainer role on the destination group to import to. Using the Developer role for this purpose was
[deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/387891) in GitLab 15.8 and will be removed in GitLab 16.0.
2020-06-23 00:09:42 +05:30
## Caveats
2022-08-13 15:12:31 +05:30
If the GitHub [rate limit](https://docs.github.com/en/rest/rate-limit) is reached while
2021-04-17 20:07:23 +05:30
importing, the importing process waits (`sleep()`) until it can continue importing.
2020-06-23 00:09:42 +05:30
2018-12-13 13:39:08 +05:30
## Importing multiple projects
2017-08-17 22:00:37 +05:30
To import a project from the list of your GitHub projects available:
2020-03-13 15:44:24 +05:30
```shell
2017-08-17 22:00:37 +05:30
# Omnibus installations
2018-12-13 13:39:08 +05:30
sudo gitlab-rake "import:github[access_token,root,foo/bar]"
2017-08-17 22:00:37 +05:30
# Installations from source
2018-12-13 13:39:08 +05:30
bundle exec rake "import:github[access_token,root,foo/bar]" RAILS_ENV=production
2017-08-17 22:00:37 +05:30
```
In this case, `access_token` is your GitHub personal access token, `root`
2021-02-22 17:27:13 +05:30
is your GitLab username, and `foo/bar` is the new GitLab namespace/project
2023-04-23 21:23:45 +05:30
created from your GitHub project. Subgroups are also possible: `foo/foo/bar`.
2017-08-17 22:00:37 +05:30
2018-12-13 13:39:08 +05:30
## Importing a single project
2017-08-17 22:00:37 +05:30
To import a specific GitHub project (named `foo/github_repo` here):
2020-03-13 15:44:24 +05:30
```shell
2017-08-17 22:00:37 +05:30
# Omnibus installations
2018-12-13 13:39:08 +05:30
sudo gitlab-rake "import:github[access_token,root,foo/bar,foo/github_repo]"
2017-08-17 22:00:37 +05:30
# Installations from source
2018-12-13 13:39:08 +05:30
bundle exec rake "import:github[access_token,root,foo/bar,foo/github_repo]" RAILS_ENV=production
2017-08-17 22:00:37 +05:30
```