Skip to content

Commit ec47170

Browse files
authored
Add CN doc for Gitlab mirror (#195)
- Add Chinese doc for Gitlab mirror - Update doc Follow up: #194
1 parent 7a3ba42 commit ec47170

File tree

2 files changed

+40
-27
lines changed

2 files changed

+40
-27
lines changed

README.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22

33
简体中文 | [English](./README_en.md)
44

5-
一个用于在hub间(例如Github,Gitee)账户代码仓库同步的action
5+
一个用于在hub间(例如Github,Gitee和Gitlab)账户代码仓库同步的action
66

77
## 用法
88

9+
### 同步GitHub到Gitee
910
```yaml
1011
steps:
1112
- name: Mirror the Github organization repos to Gitee.
1213
uses: Yikun/hub-mirror-action@master
1314
with:
15+
# 支持Gitee, Github and Gitlab
1416
src: github/kunpengcompute
17+
# 支持Gitee, Github and Gitlab
1518
dst: gitee/kunpengcompute
1619
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
1720
dst_token: ${{ secrets.GITEE_TOKEN }}
21+
# 支持Github/Gitee的用户、组织以及Gitlab的组
1822
account_type: org
23+
# 支持分别设置源和目的端的类型
1924
# src_account_type: org
2025
# dst_account_type: org
2126
```
@@ -34,13 +39,13 @@ steps:
3439
#### 必选参数
3540
- `src` 需要被同步的源端账户名,如github/kunpengcompute,表示Github的kunpengcompute账户。
3641
- `dst` 需要同步到的目的端账户名,如gitee/kunpengcompute,表示Gitee的kunpengcompute账户。
37-
- `dst_key` 用于在目的端上传代码的私钥(默认可以从~/.ssh/id_rsa获取),可参考[生成/添加SSH公钥](https://gitee.com/help/articles/4181)[generating SSH keys](https://docs.github.com/articles/generating-an-ssh-key/)生成,并确认对应公钥已经被正确配置在目的端。对应公钥,Github可以在[这里](https://github.com/settings/keys)配置,Gitee可以[这里](https://gitee.com/profile/sshkeys)配置。
38-
- `dst_token` 创建仓库的API tokens, 用于自动创建不存在的仓库,Github可以在[这里](https://github.com/settings/tokens)找到,Gitee可以在[这里](https://gitee.com/profile/personal_access_tokens)找到。
42+
- `dst_key` 用于在目的端上传代码的私钥(默认可以从~/.ssh/id_rsa获取),可参考[生成/添加SSH公钥](https://gitee.com/help/articles/4181)[generating SSH keys](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)生成,并确认对应公钥已经被正确配置在目的端。对应公钥,Github可以在[这里](https://github.com/settings/keys)配置,Gitee可以[这里](https://gitee.com/profile/sshkeys)配置,Gitlab可以在[这里](https://gitlab.com/-/user_settings/ssh_keys)配置。
43+
- `dst_token` 创建仓库的API tokens, 用于自动创建不存在的仓库,Github可以在[这里](https://github.com/settings/tokens)找到,Gitee可以在[这里](https://gitee.com/profile/personal_access_tokens)找到,Gitlab可以在[这里](https://gitlab.com/-/user_settings/personal_access_tokens)找到(Required scopes: api, read_api, read_repository, write_repository)
3944

4045
#### 可选参数
41-
- `account_type` 默认为user,源和目的的账户类型,可以设置为org(组织)或者user(用户),该参数支持**同类型账户**(即组织到组织,或用户到用户)的同步。如果源目的仓库是不同类型,请单独使用`src_account_type``dst_account_type`配置。
42-
- `src_account_type` 默认为`account_type`,源账户类型,可以设置为org(组织)或者user(用户)。
43-
- `dst_account_type` 默认为`account_type`,目的账户类型,可以设置为org(组织)或者user(用户)。
46+
- `account_type` 默认为user,源和目的的账户类型,可以设置为org(组织)、user(用户)或者group(组),该参数支持**同类型账户**(即组织到组织,或用户到用户,或组到组)的同步。如果源目的仓库是不同类型,请单独使用`src_account_type``dst_account_type`配置。
47+
- `src_account_type` 默认为`account_type`,源账户类型,可以设置为org(组织)、user(用户)或者group(组)。
48+
- `dst_account_type` 默认为`account_type`,目的账户类型,可以设置为org(组织)、user(用户)或者group(组)。
4449
- `clone_style` 默认为https,可以设置为ssh或者https。当设置为ssh时,你需要将`dst_key`所对应的公钥同时配置到源端和目的端。
4550
- `cache_path` 默认为'', 将代码缓存在指定目录,用于与actions/cache配合以加速镜像过程。
4651
- `black_list` 默认为'', 配置后,黑名单中的repos将不会被同步,如“repo1,repo2,repo3”。
@@ -195,13 +200,30 @@ steps:
195200
lfs: true
196201
```
197202

203+
#### 同步GitHub到Gitlab
204+
```yaml
205+
- name: GitLab group mirror
206+
uses: Yikun/hub-mirror-action@master
207+
with:
208+
src: github/organization-name
209+
dst: gitlab/group-name
210+
dst_key: ${{ secrets.GITLAB_PRIVATE_KEY }}
211+
dst_token: ${{ secrets.GITLAB_TOKEN }}
212+
account_type: group
213+
src_account_type: org
214+
dst_account_type: group
215+
```
216+
198217
## FAQ
199218

200219
- 如何在secrets添加dst_token和dst_key?
201220
下面是添加secrets的方法,也可以参考[secrets官方文档](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets)了解更多:
202-
1. **获取Token和Key**,分别获取[ssh key](https://gitee.com/profile/sshkeys)和[token](https://gitee.com/profile/personal_access_tokens)。
203-
2. **增加Secrets配置**,在配置仓库的Setting-Secrets中新增Secrets,例如GITEE_PRIVATE_KEY、GITEE_TOKEN
204-
3. **在Workflow中引用**, 可以用过类似`${{ secrets.GITEE_PRIVATE_KEY }}`来访问
221+
1. **获取Token和Key**,例如
222+
- Github: 配置并保存[ssh key](https://github.com/settings/keys)和[token](https://github.com/settings/tokens)
223+
- Gitee: 配置并保存[ssh key](https://gitee.com/profile/sshkeys)和[token](https://gitee.com/profile/personal_access_tokens)
224+
- Gtilab: 配置并保存[ssh key](https://gitlab.com/-/user/settings/keys)和[token](https://gitlab.com/-/user_settings/personal_access_tokens)
225+
2. **增加Secrets配置**,在配置仓库的Setting-Secrets中新增Secrets,例如`GITEE_PRIVATE_KEY`\`GITLAB_PRIVATE_KEY`、`GITEE_TOKEN`\`GITLAB_TOKEN`。
226+
3. **在Workflow中引用**, 可以用过类似`${{ secrets.GITEE_PRIVATE_KEY }}`来访问。
205227

206228
## 参考
207229
- [Hub mirror template](https://github.com/yi-Xu-0100/hub-mirror): 一个用于展示如何使用这个action的模板仓库. from @yi-Xu-0100

README_en.md

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,28 @@ Action for mirroring repos between Hubs (like GitHub, Gitee, and GitLab).
66

77
## Tutorial
88

9-
### Mirror GitHub to Gitee
109
```yaml
1110
steps:
1211
- name: Mirror the Github organization repos to Gitee.
1312
uses: Yikun/hub-mirror-action@master
1413
with:
14+
# Support gitee, github and gitlab
1515
src: github/kunpengcompute
16+
# Support gitee, github and gitlab
1617
dst: gitee/kunpengcompute
1718
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
1819
dst_token: ${{ secrets.GITEE_TOKEN }}
20+
# Support github/gitee user, org and gitlab group
1921
account_type: org
22+
# Supporte set account type speparately
2023
# src_account_type: org
2124
# dst_account_type: org
2225
```
23-
### Mirror GitHub to Gitlab
24-
```yaml
25-
steps:
26-
- name: Mirror the GitHub organization repos to GitLab.
27-
uses: Yikun/hub-mirror-action@master
28-
with:
29-
src: github/kunpengcompute
30-
dst: gitlab/kunpengcompute
31-
dst_key: ${{ secrets.GITLAB_PRIVATE_KEY }}
32-
dst_token: ${{ secrets.GITLAB_TOKEN }}
33-
account_type: group
34-
src_account_type: org
35-
dst_account_type: group
36-
```
37-
3826

3927
Here is a workflow to mirror the kunpengcompute org repos from Github to Gitee, see more complete workflows in [here](https://github.com/Yikun/hub-mirror-action/tree/master/.github/workflows).
4028

29+
Please refer to [scenarios](https://github.com/Yikun/hub-mirror-action/blob/master/README_en.md#scenarios) for more examples.
30+
4131
## Who are using?
4232
More than [100+](https://github.com/search?p=2&q=hub-mirror-action+%22account_type%22+%22org%22&type=Code) organizations,[4000+](https://github.com/search?l=YAML&q=%22hub-mirror-action%22&type=Code) users are using, [50+](https://github.com/search?l=Markdown&q=%22hub-mirror-action%22&type=code) related blogs from users:
4333

@@ -215,8 +205,9 @@ Note: please configure the public key of `dst_key` to the source (github in here
215205
You can use below steps to add secrets, you can also see more in [Secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets).
216206

217207
1. **Get Token and Key**:
218-
* For Gitee: Get SSH key from [here](https://gitee.com/profile/sshkeys) and token from [here](https://gitee.com/profile/personal_access_tokens)
219-
* For GitLab: Get SSH key from [here](https://gitlab.com/-/user_settings/ssh_keys) and token from [here](https://gitlab.com/-/user_settings/personal_access_tokens)
208+
- Github: Configure and save your [ssh key](https://github.com/settings/keys)和[token](https://github.com/settings/tokens)
209+
- Gitee: Configure and save your [ssh key](https://gitee.com/profile/sshkeys)和[token](https://gitee.com/profile/personal_access_tokens)
210+
- Gtilab: Configure and save your [ssh key](https://gitlab.com/-/user/settings/keys)和[token](https://gitlab.com/-/user_settings/personal_access_tokens)
220211
2. **Add Secrets**,add settings-secrets in repo,like `GITEE_PRIVATE_KEY`、`GITEE_TOKEN` or `GITLAB_PRIVATE_KEY`、`GITLAB_TOKEN`
221212
3. **Add workflow**,add the workflow file into .github/workflows.
222213

0 commit comments

Comments
 (0)