hub-mirror-action icon indicating copy to clipboard operation
hub-mirror-action copied to clipboard

Add dst_visibility support

Open Yikun opened this issue 2 years ago • 8 comments

Due some well known issue of gitee repo policy, we have to add a friendly parameter to support mirror the repo as private repo.

Take below yaml as example:

- name: Mirror the Github organization repos to Gitee.
  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
    # mirror hashes and simple-spring repo
    static_list: 'hashes,simple-spring'
    # these repos will be mirrored as private repo
    dst_visibility: 'private'

This will help to create mirror as private repo.

Close:

  • https://github.com/Yikun/hub-mirror-action/issues/159
  • https://github.com/Yikun/hub-mirror-action/issues/155

Related: https://github.com/Yikun/hub-mirror-action/issues/38

CO-AUTHORED-BY: @dislazy

Yikun avatar Jun 07 '22 02:06 Yikun

cc @yi-Xu-0100 @Zephyr5 @OxalisCu @ufoozhenghao @xiexianbin @sunleonx @appotry

Would you mind have a test? I cc the people who was involved in related issue.

- name: Use specific branch.
  uses: Yikun/hub-mirror-action@dst_visibility

Yikun avatar Jun 07 '22 02:06 Yikun

Convenient. How do I configure it? Can I communicate in Chinese

sean3306 avatar Jun 07 '22 12:06 sean3306

@sunleonx 可以哈,参考PR描述里的例子

- name: Mirror the Github organization repos to Gitee.
  uses: Yikun/hub-mirror-action@dst_visibility
  with:
    src: github/Yikun
    dst: gitee/yikunkero
    dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
    dst_token:  ${{ secrets.GITEE_TOKEN }}
    force_update: true
    debug: true
    # mirror hashes and simple-spring repo
    static_list: 'hashes,simple-spring'
    # these repos will be mirrored as private repo
    dst_visibility: 'private'
    # if need read src private repo, pls use ssh clone style, and set dst_key to github and gitee
    clone_style: 'ssh'

Yikun avatar Jun 07 '22 15:06 Yikun

还是存在同样的问题 image

sean3306 avatar Jun 08 '22 03:06 sean3306

  • 配置文件如下
# 通过 Github actions, 在 Github 仓库的每一次 commit 后自动同步到 Gitee 上
name: sync2gitee
on:
  push:
    branches:
      - master
jobs:
  repo-sync:
    env:
      dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
      dst_token: ${{ secrets.GITEE_TOKEN }}
      gitee_user: ${{ secrets.GITEE_USER }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          persist-credentials: false

      - name: sync github -> gitee
        uses: Yikun/hub-mirror-action@dst_visibility
        if: env.dst_key && env.dst_token && env.gitee_user
        with:
          # 必选,需要同步的 Github 用户(源)
          src: 'github/${{ github.repository_owner }}'
          # 必选,需要同步到的 Gitee 用户(目的)
          dst: 'gitee/${{ secrets.GITEE_USER }}'
          # 必选,Gitee公钥对应的私钥,https://gitee.com/profile/sshkeys
          dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
          # 必选,Gitee对应的用于创建仓库的token,https://gitee.com/profile/personal_access_tokens
          dst_token:  ${{ secrets.GITEE_TOKEN }}
          force_update: true
          debug: true
          # 如果是组织,指定组织即可,默认为用户 user
          account_type: org
          # 直接取当前项目的仓库名
          static_list: 'contract-admin-ui'
          dst_visibility: 'private'
          # 还有黑、白名单,静态名单机制,可以用于更新某些指定库
          # static_list: 'repo_name,repo_name2'
          # black_list: 'repo_name,repo_name2'
          # white_list: 'repo_name,repo_name2'

sean3306 avatar Jun 08 '22 03:06 sean3306

目前仓库属于github的私有仓库和gitee企业版本的私有仓库

sean3306 avatar Jun 08 '22 03:06 sean3306

    # if need read src private repo, pls use ssh clone style, and set dst_key to github and gitee
    clone_style: 'ssh'

如果需要读取private仓,再加上clone_style @sunleonx

Yikun avatar Jun 08 '22 03:06 Yikun

image

sean3306 avatar Jun 08 '22 03:06 sean3306