a tools Mirrors Code from Github to Gitee.
- Support Private/Public Organization/User 's Repos sync
- Support The Sample Git Provides sync, like
github.com/xiexianbin/test
github.com/x-actions/test
兼容 Yikun/hub-mirror-action
src
github/<name>
name 可以是 user name 或 org name, eg:github/xiexianbin
src_token
😄扩展参数
,源的 API tokens,支持 Gitee、Github- 若配置为
${{ secrets.GITHUB_TOKEN }}
,仅支持同步公开仓库,Github Action 会中自动注入 token - 若需要同步私有仓库,需配置 ${{ secrets.PERSONAL_ACCESS_TOKEN }},
PERSONAL_ACCESS_TOKEN
在这里创建
- 若配置为
dst
gitee/<name>
name 可以是 user name 或 org name, eg:gitee/xiexianbin
dst_key
目的端和源端的 ssh public keydst_token
创建仓库的API tokens,支持Gitee、Github
account_type
org(Organization) or user, default is usersrc_account_type
默认为account_type,源账户类型,可以设置为org(组织)或者user(用户)。dst_account_type
默认为account_type,目的账户类型,可以设置为org(组织)或者user(用户)。clone_style
just support ssh, anddst_key
must configure both github and giteecache_path
默认为'',将代码缓存在指定目录,用于与 actions/cache配合以加速镜像过程。black_list
默认为'',配置后,黑名单中的repos将不会被同步,如“repo1,repo2,repo3”。white_list
默认为'',配置后,仅同步白名单中的repos,如“repo1,repo2,repo3”。force_update
默认为false
, 配置后,启用git push -f
强制同步,注意:开启后,会强制覆盖目的端仓库。debug
默认为false
, 配置后,启用debug开关,会显示所有执行命令。timeout
默认为'30m', 用于设置每个git命令的超时时间,'600'=>600s, '30m'=>30 mins, '1h'=>1 hoursmappings
源仓库映射规则,比如'A=>B, C=>CC', A会被映射为B,C会映射为CC,映射不具有传递性。主要用于源和目的仓库名不同的镜像。ssh_keyscans
😄扩展参数
,默认为github.com,gitee.com
- Github Action
Sample Use
- name: git mirror
uses: x-actions/git-mirrors@main
with:
src: github/${{ matrix.github }}
src_token: ${{ secrets.GITHUB_TOKEN | secrets.PERSONAL_ACCESS_TOKEN }}
dst: gitee/${{ matrix.gitee }}
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
account_type: user
cache_path: "/github/workspace/git-mirrors-cache"
black_list: "openbilibili,test1"
clone_style: ssh
all Params
- name: git mirror
uses: x-actions/git-mirrors@main
with:
src: github/${{ matrix.github }}
src_token: ${{ secrets.GITHUB_TOKEN }}
dst: gitee/${{ matrix.gitee }}
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
account_type: user
# src_account_type: org
# dst_account_type: org
cache_path: "/github/workspace/git-mirrors-cache"
black_list: "openbilibili,test1"
white_list: "w1,w2"
clone_style: ssh
force_update: false
debug: true
timeout: 30m
mappings: "A=>B, C=>CC"
- command line
# download
curl -Lfs -o git-mirrors https://github.com/x-actions/git-mirrors/releases/latest/download/git-mirrors-{linux|darwin|windows}
chmod +x git-mirrors
# help
./git-mirrors -h
# demo
git-mirrors \
--src "github/estack" \
--src-token "${GITHUB_TOKEN}" \
--dst "gitee/e-stack" \
--dst-key "" \
--dst-token "${GITEE_TOKEN}" \
--account-type "user" \
--clone-style "ssh" \
--cache-path "./temp/" \
--black-list "" \
--white-list "" \
--force-update=true \
--debug=true \
--timeout "10m"
- ssh key err
clone git@github.com:xx/xx.git err: unknown error: ERROR: You're using an RSA key with SHA-1, which is no longer allowed. Please use a newer client or a different key type.
regenerate ssh key:
$ ssh-keygen -t ed25519 -C "your_email@example.com"
# or
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
more info go to https://github.blog/2021-09-01-improving-git-protocol-security-github/
- git ssh
[git clone git@github.com:xxx/xxx.git] in path /github/workspace/git-mirrors-cache/xxx/xxx
[ERROR] [1/29] (1/36) mirror occur err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
dst_key
must configure both github
and gitee
- 采用兼容 Yikun/hub-mirror-action 的配置参数,因此不可避免的参考其实现,在此表示感谢。