Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法同步私有仓库 #38

Open
yi-Xu-0100 opened this issue Sep 9, 2020 · 18 comments
Open

无法同步私有仓库 #38

yi-Xu-0100 opened this issue Sep 9, 2020 · 18 comments
Labels
feature New feature or request priority/wishlist

Comments

@yi-Xu-0100
Copy link
Contributor

能否给出解决方案将 github 的私有仓库同步到 gitee 的私有仓库?

@Yikun Yikun added the feature New feature or request label Sep 10, 2020
@Yikun
Copy link
Owner

Yikun commented Sep 10, 2020

@yi-Xu-0100 目前暂无支持计划。

另外,这个如果加的话,需要引入新的配置项:

  1. 目的端的token:用于创建私有仓。
  2. 源端的token:用于访问私有仓。

@yi-Xu-0100
Copy link
Contributor Author

非常感谢,期待未来的更新,暂时对相关方面作不同步处理。☺

@Zephyr5
Copy link

Zephyr5 commented Dec 10, 2020

求支持私有仓库 👍

@yinyuncan
Copy link

求支持私有仓库

@OxalisCu
Copy link

OxalisCu commented Apr 4, 2022

我也遇到了不能同步私有仓库的问题:
通过actions/github-script和github-token获取私有库名成功,但是Yikun/hub-mirror-action@master下载github库的时候失败,错误如下
image
并且将仓库设为公开后同步成功
不知道这个是否是因为hub-morror-action还不支持同步私有库,如果是的话希望能进行支持,respect

@Yikun
Copy link
Owner

Yikun commented Apr 9, 2022

@yi-Xu-0100 突然想到,如果依赖你的action获取私有仓库(替代src_token),加上把dst_key分别配置到github和gitee侧(替代src_key),再加上#152

是不是就可以支持仅私有仓同步了?

另外,之所以不想增加私有仓的同步是因为我觉得权限有点高,因为一些误配置导致私有仓泄露。

另外,前提是你的action支持gitee的repo list。

@yi-Xu-0100
Copy link
Contributor Author

@Yikun 首先,我的 repo-list-generator 暂时只是支持获取 github 的仓库列表,只是为了方便获得仓库目录用来同步,后续会尝试实现 gitee 端的功能。

但是我对这个同步私有仓库有一定的建议。

之所以不想增加私有仓的同步是因为我觉得权限有点高,因为一些误配置导致私有仓泄露。

我们可以增加一个参数用来同步私有仓库。比如:private: true(default: false)。也就是只有当 private 设置参数为 true 时,会将仓库名单全部同步到私有仓库(公有->私有,私有->私有)。

这样,我们不会考虑将私用同步到公有的可能,如果有这个需要,我建议是直接将仓库公有后,再同步。也就是从源头杜绝操作私有仓库公有化。

而私有仓库的同步,则只有个人设置相关参数用来控制同步私有仓库,所以理论上是自己操作完成的。

最后,对于会将仓库名单全部同步到私有仓库(公有->私有,私有->私有),则是为了将公有仓库转私有,或者私有仓库同步的2种问题的共同解决。也同时是建议使用 static_list 去完成设置的。

@Yikun
Copy link
Owner

Yikun commented Apr 9, 2022

我们可以增加一个参数用来同步私有仓库。比如:private: true(default: false)。

这个就是 #152 做的事情。cc @dislazy

如果后续我们想不依赖repo-list-generator的话,我们也可以新增src_private: false/true/all来控制源仓的获取。当然,前提是src_token也支持了。

另外,再想想:

  1. 参数命名:
    private VS dst_private VS dst_visibility,因为后续获取会存在src_private/visibility,来控制是否同步源private仓库。
  2. 参数值:dst_private true代表同步为私有仓,false代表同步为公有仓,后续是不是还会有个auto,来根据src repo类型自动处理。
  3. visibility是不是更合适?
  • dst_visibility: private/public/auto,默认为auto
  • src_visibility: private/public/all,默认为public

当然,对于 #152 来说,先支持:dst_visibility: private/public,默认为public

@Yikun
Copy link
Owner

Yikun commented Apr 9, 2022

@OxalisCu

通过actions/github-script和github-token获取私有库名成功,但是Yikun/hub-mirror-action@master下载github库的时候失败

这个是因为http模式目前无法读取私有仓,所以,当上面评论的实现完成,我们仅支持ssh模式的私有仓同步。

@Yikun
Copy link
Owner

Yikun commented Apr 9, 2022

- name: Get private repository list
  id: repo
  uses: yi-Xu-0100/repo-list-generator@v1.0.1
  with:
    # 使用src_token获取私有仓
    my_token: ${{ secrets.SRC_TOKEN }}
- name: Mirror private repository
  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_PRIVATE }}
    # 使用ssh模式,并且需要用户将dst_key配置到远端及目的端
    clone_style: ssh
    # 同步仓库的可见性为private,如果已存在则直接同步,不做可见性更新。
    dst_visibility: private

#152 支持后。单独同步私有仓的最终形式应该是这样的。

@yi-Xu-0100
Copy link
Contributor Author

@Yikun 就像 #49 所说的,如果想获取私有仓库,src_token 应该也是需要的。

@Yikun
Copy link
Owner

Yikun commented Apr 10, 2022

@yi-Xu-0100 hub-mirror–action不需要src_token,只需要用repo list拿到私有仓列表就行了。

@ufoozhenghao
Copy link

遇到了这个问题 保持关注

@xiexianbin
Copy link

因有个人私有仓库的备份需求,且暂未找到私有仓库的同步方法。因此,参考 Yikun/hub-mirror-action 配置,使用 golang 重写同步功能 x-actions/git-mirrors,支持私有仓库从 github 同步到 gitee,一个不成熟的测试示例见 xiexianbin/gitee@702b899

@Yikun
Copy link
Owner

Yikun commented Jun 7, 2022

@xiexianbin 赞一个~ 可以参考这个:#88 (comment) 之前也有类似的想法。

因为可能每个同学的背景不太一样,所以,有不同种的语言背景,如果我们有多个语言的版本,可以合一作为一个组织,这样后续各种语言背景的同学,都可以参与进来。

@Yikun
Copy link
Owner

Yikun commented Jun 7, 2022

#160 这个PR添加了dst_visibility参数,来控制同步的目的仓是私有仓还是共有仓。

主要背景是:Gitee由于一些原因改变策略,普通用户无法直接创建共有仓库,因此,对于github到gitee同步的用户,可能亟需以私仓同步的功能。

我在 #38 (comment) 也提及了,后续API的可能演进方向:

  • dst_visibility: private/public/auto,private表示同步为私有仓,public同步为共有仓(当前默认行为),auto表示根据原仓属性自动读取。
  • src_visibility: private/public/all。public表示只同步共有仓,private表示只同步私有仓,all表示全部仓库都同步

当然,这个参数的引入,也意味着在一定程度上已经支持了私有仓的同步:

- name: Mirror private repo.
  uses: Yikun/hub-mirror-action@master
  with:
    src: github/Yikun
    dst: gitee/yikunkero
    # 使用ssh方式clone,保证原仓的可读性
    clone_style: "ssh"
    # ssh模式目前需要将dst_key配置到原仓和目的仓
    dst_key: ${{ secrets.GITEE_AND_GITHUB_PRIVATE_KEY }}
    dst_token:  ${{ secrets.GITEE_TOKEN }}
    # 目前列表只能指定为静态
    static_list: 'hashes,simple-spring'
    # 目的端的可见性设置为私有仓
    dst_visibility: 'private'

@xiexianbin
Copy link

@Yikun 听起来不错。

@xiexianbin 赞一个~ 可以参考这个:#88 (comment) 之前也有类似的想法。

因为可能每个同学的背景不太一样,所以,有不同种的语言背景,如果我们有多个语言的版本,可以合一作为一个组织,这样后续各种语言背景的同学,都可以参与进来。

听起来不错,支持

@MikasaEureka
Copy link

插眼关注,私有仓库现在是不是只能通过提高token权限这么弄呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request priority/wishlist
Projects
None yet
Development

No branches or pull requests

8 participants