English | 简体中文
Action for mirroring repos between Hubs (like Github and Gitee)
steps:
- name: Mirror the Github organization repos to Gitee.
uses: Yikun/hub-mirror-action@master
with:
src: github/kunpengcompute
dst: gitee/kunpengcompute
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
account_type: org
# src_account_type: org
# dst_account_type: org
Here is a workflow to mirror the kunpengcompute org repos from Github to Gitee, see more complete workflows in here.
More than 100+ organizations,4000+ users are using, 50+ related blogs from users:
src
source account, such asgithub/kunpengcompute
, is the Github kunpengcompute account.dst
Destination account, such as/kunpengcompute
, is the Gitee kunpengcompute account.dst_key
the private key to push code in destination account (default in ~/.ssh/id_rsa), you can see generating SSH keys to generate the pri/pub key, and make sure the pub key has been added in destination. You can set Github ssh key in here,set the Gitee ssh key in here.dst_token
the API token to create non-existent repo, You can get Github token in here, and the Gitee in here.
account_type
(optional) default isuser
, the account type of src and dst account, can be set toorg
oruser
,only support mirror between same account type (that is "org to org" or "user to user"). if u wanna mirror difference account type, use thesrc_account_type
anddst_account_type
please.src_account_type
(optional) default isaccount_type
, the account type of src account, can be set toorg
oruser
.dst_account_type
(optional) default isaccount_type
, the account type of dst account, can be set toorg
oruser
.clone_style
(optional) default ishttps
, can be set tossh
orhttps
.When you are using ssh clone style, you need to configure the public key ofdst_key
to both source end and destination end.cache_path
(optional) let code clone in specific path, can be used with actions/cache to speed up mirror.black_list
(optional) the black list, such as “repo1,repo2,repo3”.white_list
(optional) the white list, such as “repo1,repo2,repo3”.static_list
(optional) Only mirror repos in the static list, but don't get list from repo api dynamically (the white/black list is still available). like 'repo1,repo2,repo3'force_update
(optional) Force to update the destination repo, use '-f' flag do 'git push'timeout
(optional) Default is '30m', set the timeout for every git command, like '600'=>600s, '30m'=>30 mins, '1h'=>1 hoursmappings
(optional) Default is empty, the source repos mappings, such as 'A=>B, C=>CC', source repo name would be mapped follow the rule: A to B, C to CC. Mapping is not transitive.
- name: Organization mirror
uses: Yikun/hub-mirror-action@master
with:
src: github/kunpengcompute
dst: gitee/kunpengcompute
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
account_type: org
- name: Single repo mirror
uses: Yikun/hub-mirror-action@master
with:
src: github/Yikun
dst: gitee/yikunkero
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
white_list: "hub-mirror-action"
white_list: "hashes"
- name: Black list
uses: Yikun/hub-mirror-action@master
with:
src: github/Yikun
dst: gitee/yikunkero
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
static_list: "hub-mirror-action,hashes"
Note: please configure the public key of dst_key
to the source (github in here) and destination(gitee in here)
- name: ssh clone style
uses: Yikun/hub-mirror-action@master
with:
src: github/Yikun
dst: gitee/yikunkero
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
clone_style: "ssh"
- name: Mirror with specific cache
uses: Yikun/hub-mirror-action@master
with:
src: github/Yikun
dst: gitee/yikunkero
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
cache_path: /github/workspace/hub-mirror-cache
- name: Mirror with force push (git push -f)
uses: Yikun/hub-mirror-action@master
with:
src: github/Yikun
dst: gitee/yikunkero
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
force_update: true
debug: true
- name: Mirror with force push (git push -f)
uses: Yikun/hub-mirror-action@master
with:
src: github/Yikun
dst: gitee/yikunkero
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
force_update: true
timeout: '1h'
- name: mirror with mappings
uses: Yikun/hub-mirror-action@mappings
with:
src: github/yikun
dst: gitee/yikunkero
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
mappings: "yikun.github.com=>blog"
static_list: "yikun.github.com"
- name: Get repository list exclude private and fork
id: repo
uses: yi-Xu-0100/repo-list-generator@v1.0.1
- name: Mirror repository list exclude private and fork
uses: Yikun/hub-mirror-action@master
with:
src: github/Yikun
dst: gitee/yikunkero
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
static_list: ${{ steps.repo.outputs.repoList }}
-
How to use
secrets
to add token and key?You can use below steps to add secrets, you can also see more in Secrets.
- Hub mirror template: A template repo to show how to use this action. from @yi-Xu-0100
- Auto-Sync GitHub Repositories to Gitee: An introduction about how to use this action. from @ShixiangWang
- Use Github Action to sync reois to Gitee: The blog for this action.