Home

Awesome

Hub Mirror Action

简体中文 | English

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

用法

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

上面的配置完成了kunpencompute组织从github到gitee的同步,你可以在测试和demo找到完整用法。

有疑问、想法、问题、建议,可以通过Gitter找到我们。

谁在使用?

超过100+组织,4000+使用者正在使用,50+来自使用者的使用教程:

<img src="https://user-images.githubusercontent.com/1736354/130942306-7bfc32b7-ad2e-4117-b29d-17562c6536d6.jpg" width="90"></a><a href="https://github.com/openeuler-mirror/sync-config/blob/master/.github/workflows/repo-mirror.yml" > <img src="https://user-images.githubusercontent.com/1736354/130942376-279b5267-4842-41f0-b251-084acfd706a8.jpg" width="90"></a><a href="https://github.com/Ascend/infrastructure/blob/master/.github/workflows/repo-mirror.yml" > <img src="https://user-images.githubusercontent.com/1736354/130942173-afd2ad34-3ba1-4a6e-b0eb-b72050239c46.jpg" width="90"></a><a href="https://github.com/mindspore-ai/infrastructure/blob/master/.github/workflows/repos-mirror.yml" ><img src="https://user-images.githubusercontent.com/1736354/130942787-b01f79a9-c115-46fd-a2b0-23e5f84cba61.jpg" width="90"></a> <a href="https://github.com/opengauss-mirror/sync-config/blob/master/.github/workflows/repo-mirror.yml" ><img src="https://user-images.githubusercontent.com/1736354/130942900-f8ff41bb-a827-425c-a132-569ba78ed18c.jpg" width="90"></a> <a href="https://github.com/openlookeng/sync-config/blob/master/.github/workflows/repo-mirror.yml" ><img src="https://user-images.githubusercontent.com/1736354/130942988-c32b0224-ecc2-454a-b5e8-376ae25c092d.jpg" width="90"></a><a href="https://github.com/openharmony" > <img src="https://user-images.githubusercontent.com/1736354/130943738-6a8fb234-7829-4b70-a8a7-1716fda2c5b5.jpg" width="90"></a><a href="https://github.com/EdgeGallery/sync-gitee-repo/blob/master/.github/workflows/gitee-repo-mirror.yml" > <img src="https://user-images.githubusercontent.com/1736354/130944072-b4eb2ca2-ab15-456f-946b-043c114dc783.jpg" width="90"></a><a href="https://github.com/kunpengcompute/Kunpeng/blob/master/.github/workflows/gitee-repos-mirror.yml" > <a href="https://github.com/WeBankFinTech/fes.js/blob/master/.github/workflows/gitee-mirror.yml" ><img src="https://user-images.githubusercontent.com/1736354/130943240-f08ba34f-7971-4e17-8ee2-35b8718aba28.jpg" width="90"></a><a href="https://github.com/openbiox/UCSCXenaShiny/blob/master/.github/workflows/sync-gitee.yml" ><img src="https://user-images.githubusercontent.com/1736354/95940344-aaa2e580-0e10-11eb-863d-1ff2c5a04cfa.jpg" width="90"></a><a href="https://github.com/renwu-cool/mirror-action/blob/master/.github/workflows/main.yml" ><img src="https://user-images.githubusercontent.com/1736354/95940437-eb9afa00-0e10-11eb-9fe2-65a8e68c6698.jpg" width="90"></a><a href="https://github.com/kubesphere/website/blob/c7ebf051d2b7d712b88cccf5424fae0cef6c1c82/.github/workflows/build.yml"><img src="https://user-images.githubusercontent.com/1736354/131271726-5f5e1f75-2e84-40d6-99ac-0bceaca41b2a.jpg" width="90"></a> <a href="https://github.com/go-atomci/atomci/blob/master/.github/workflows/sync-to-gitee.yml"><img src="https://user-images.githubusercontent.com/1736354/147518496-d92da9f1-24ed-4fde-b170-5559aa0512ff.png" width="90"></a> <a href="https://github.com/RapidAI/.github/blob/main/.github/workflows/SyncToGitee.yml"><img src="https://user-images.githubusercontent.com/28639377/226772424-1a926e15-f418-4371-8750-c0826ef92cd8.png" width="90"></a> <a href="https://github.com/search?q=hub-mirror-action&type=code"><img src="https://user-images.githubusercontent.com/1736354/95940571-42a0cf00-0e11-11eb-9ee2-cd497b50f06a.png" width="90"></a>

参数详解

必选参数

可选参数

举些例子

组织同步

同步Github的kunpengcompute组织到Gitee

- 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

黑/白名单

动态获取源端github/Yikun的repos,但仅同步名为hub-mirror-action,不同步hashes这个repo到Gitee

- 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"
    black_list: "hashes"

静态名单(可用于单一仓库同步)

不会动态获取源端github/Yikun的repos,仅同步hub-mirror-action这个repo

- 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"

clone方式

使用ssh方式进行clone

说明:请把dst_key所的公钥配置到源端(在这里为github)及目的端(在这里为gitee)

- 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"

指定目录cache

- 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

强制更新,并打开debug日志开关

- 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

设置命令行超时时间为1小时

- 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'

仓库名不同时同步(github/yikun/yikun.github.com to gitee/yikunkero/blog)

- 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"

仅同步非fork且非private的仓库

- 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 }}

支持LFS同步

- name: Mirror with lfs (git lfs fetch/push --all)
  uses: Yikun/hub-mirror-action@master
  with:
    src: github/Yikun
    dst: gitee/yikunkero
    dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
    dst_token: ${{ secrets.GITEE_TOKEN }}
    lfs: true

FAQ

参考

最后

如果觉得不错,来个star支持下作者吧!你的Star是我更新代码的动力!:)

想任何想吐槽或者建议的都可以直接飞个issue.