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

博文定时同步 GitHub 仓库 #12676

Closed
88250 opened this Issue Feb 27, 2019 · 8 comments

Comments

3 participants
@88250
Copy link
Member

88250 commented Feb 27, 2019

特性介绍

将博文定时同步到自己的 GitHub 仓库中,每隔 24 小时做一次全量同步。

最终实现效果请看这里

应用场景与动机:

  • 通过 GitHub 让更多人看到自己的博客
  • 自动在 GitHub 仓库上备份文章

实现流程

  1. 博客端定时触发同步请求,将所有公开(非加密)文章导出 md 打 zip 包
  2. 将包发送至社区服务器,由社区服务器完成仓库创建/更新、文件提交

由社区服务器进行 GitHub 操作主要考虑到两点:

  • 安全性,避免运维过程中潜在的凭证泄露(下面会进行详细描述)
  • 可用性,由社区服务器国外节点进行操作,减少国内网络问题带来的影响

安全考量

主要涉及 GitHub 访问凭证(Access Token)的授权和使用。

凭证授权

目前博客端在进行 GitHub 登录时申请的权限包括:

  • public_repo:公开仓库相关的读写操作,比如创建仓库、Issues、提交代码等
  • read:user:读取用户信息
  • user:follow:关注/取消关注用户

具体细节可以通过该文档了解。我们仅在用户同意授权使用该功能的情况下做操作(博客端会在设置中增加是否需要同步仓库的选项,默认不同步),大家进行公开监督,避免产生不必要的误会。

凭证使用

凭证统一在社区存储,由社区统一进行运维操作,尽量避免潜在的安全泄露。所以博客端不进行凭证相关的任何存储和操作以降低风险。如果发现安全问题,我们会在 GitHub 上注销所有凭证,将安全问题产生的影响降到最低程度。


使用说明

  1. 登录博客后台,在工具 -> 偏好设定 -> 参数设置中勾选允许同步 GitHub 仓库
  2. 启动后 10 分钟进行第一次同步,后续每 24 小时触发一次

请注意:不需要 fork 我的那个仓库,程序会自动创建名为 solo-blog 的仓库。

@88250 88250 added the feature label Feb 27, 2019

@88250 88250 self-assigned this Feb 27, 2019

@88250 88250 pinned this issue Feb 27, 2019

@88250 88250 changed the title 博文定时同步 GitHub 仓库 博文定时同步 GitHub 仓库(提议阶段,欢迎参与讨论) Feb 27, 2019

@lai-bluejay

This comment has been minimized.

Copy link

lai-bluejay commented Mar 15, 2019

社区的github设置后没反应。repos不更新

@88250

This comment has been minimized.

Copy link
Member Author

88250 commented Mar 15, 2019

@lai-bluejay 收到,这个问题是程序 bug,稍后修复 😅

@88250 88250 added this to the 3.4.0 milestone Mar 17, 2019

@88250 88250 changed the title 博文定时同步 GitHub 仓库(提议阶段,欢迎参与讨论) 博文定时同步 GitHub 仓库(WIP) Mar 17, 2019

@TerickJojo

This comment has been minimized.

Copy link

TerickJojo commented Mar 18, 2019

大佬,希望这个功能设置成可选,毕竟有些文章不希望同步到github里(和代码无关的文章)。。。

@88250

This comment has been minimized.

Copy link
Member Author

88250 commented Mar 19, 2019

@TerickJojo 同步的效果不是在 GitHub 中展开每篇文章,而是上传文章 md 文件的 zip 包,仓库 READMD 里面会自动生成最新、热门、热议文章的索引,链接到博客的文章。主要目的是为博客文章数据做备份以及索引导流到博客,效果可参考这里

配置项也是有的,不过是全局的,可配置是否开启同步仓库。你感觉这样可以接受吗,或者有其他任何建议都欢迎讨论,目前还在开发中 😅

88250 added a commit that referenced this issue Mar 19, 2019

88250 added a commit that referenced this issue Mar 19, 2019

88250 added a commit that referenced this issue Mar 19, 2019

88250 added a commit that referenced this issue Mar 19, 2019

88250 added a commit that referenced this issue Mar 19, 2019

@TerickJojo

This comment has been minimized.

Copy link

TerickJojo commented Mar 19, 2019

这里

还是希望有一个配置是否开启同步仓库的功能

@88250

This comment has been minimized.

Copy link
Member Author

88250 commented Mar 19, 2019

@TerickJojo 是有的,并且默认不开启同步。

88250 added a commit that referenced this issue Mar 19, 2019

@88250 88250 changed the title 博文定时同步 GitHub 仓库(WIP) 博文定时同步 GitHub 仓库 Mar 19, 2019

@TerickJojo

This comment has been minimized.

Copy link

TerickJojo commented Mar 19, 2019

@TerickJojo 是有的,并且默认不开启同步。

多谢啦

@88250 88250 closed this Mar 20, 2019

@88250 88250 unpinned this issue Mar 20, 2019

@88250

This comment has been minimized.

Copy link
Member Author

88250 commented Mar 26, 2019

已经上线,最终效果请看这里,请不要 fork!

@b3log b3log deleted a comment from lizhongyue248 Mar 26, 2019

@b3log b3log deleted a comment from lizhongyue248 Mar 26, 2019

@b3log b3log deleted a comment from lizhongyue248 Mar 26, 2019

@b3log b3log deleted a comment from lizhongyue248 Mar 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.