github回购镜像维护工具
replicate-github的Python项目详细描述
复制github设置和维护github组织的镜像 个人回购。它可以服务于webhook端点并保持镜像的更新 连续运行,或者可以从命令行临时运行。
$ replicate-github --verbose mirror puppetlabs/puppet 'github/*' mirror.Collection: Fetching puppetlabs/puppet mirror.Collection: Fetching github/garethr-docker mirror.Collection: Fetching github/github-ldap ^C $ replicate-github --verbose serve --update-org github WebhookServer: Webhook server listening on localhost:8080 127.0.0.1 - - [10/Aug/2016 01:18:35] "POST / HTTP/1.1" 202 - mirror.Collection: Fetching puppetlabs/puppet ^C
webhook
webhook服务器接受对任何url的post(路径被忽略)。共享的 应设置secret,以便无法从非github源发送事件。
默认情况下,webhook服务器确保镜像至少在 如果没有收到任何事件,则为天。有关详细信息,请参见replicate-github serve --help。 信息。
github webhook配置
使用应用程序提供的URL下的任何URL创建Webhook。套 随机字符串的秘密,并将其放入replicate-github.yaml中,就像这样:
serve:secret:"secretconfiguredforwebhookinGitHub"
选择要发送的“存储库”和“推送”事件。
安全性
如果配置了机密,则任何不包含正确机密的事件都将 被拒绝。
仅使用有效负载的两部分:repo的全名和 已删除标志。对回购协议的全名进行验证,以确保它不包含 特殊字符(如/或)。
只要机密是 对的。这意味着如果你为一个还没有 一旦事件发生,它将开始镜像回购协议。
配置文件
配置是从--config-file的值加载的,该值默认为 /etc/replicate-github.yaml。文件需要三种设置:
mirror_path:"/srv/replicate-github"github_user:"GitHubusername"github_token:"GitHubAPItoken"
可以在Settings > Personal access tokens下生成github api令牌。
还有一个附加的顶级选项workers,用于设置 git可以同时运行的子进程。默认为1。
可选地,可以设置子命令(例如serve)的默认值:
serve:secret:"secretconfiguredforwebhookinGitHub"port:8000update_org:-github-puppetlabs
请注意,配置文件中的参数名称使用“\u”而不是“-”。为了 例如,参数--update-org在 配置文件。