nov*_*ore 40
你不需要webhook.一个普通的post-receive钩子可以很好地工作.
要创建和使用这样的钩子,您只需登录安装了gitlab的服务器,并为git用户创建一个ssh密钥.
sudo -u git ssh-keygen -f /home/git/.ssh/reponame_key
Run Code Online (Sandbox Code Playgroud)
(提示时不要输入任何密码)
转到您的github帐户,并将公钥(它已创建为/home/git/ssh/reponame_key.pub
)作为部署密钥添加到您的项目中.如果您需要帮助,请查看https://help.github.com/articles/managing-deploy-keys.
完成后,你只需配置你的git服务器和github之间的连接:为git用户的ssh配置添加一个别名(添加以下行/home/git/.ssh/config
- 如果它不存在则创建它)
Host reponame
IdentityFile /home/git/.ssh/reponame_key
HostName github.com
User git
Run Code Online (Sandbox Code Playgroud)
现在将新的远程(使用您刚刚创建的别名)添加到您的存储库:
cd /home/git/repositories/namespace/reponame.git
git remote add --mirror github reponame:youruser/reponame.git
Run Code Online (Sandbox Code Playgroud)
现在一切都到位了,你必须创建实际的钩子:
cd /home/git/repositories/namespace/reponame.git/hooks
echo "exec git push --quiet github &" >> post-receive
chmod 755 post-receive
Run Code Online (Sandbox Code Playgroud)
last命令非常重要,因为git会在运行之前检查钩子是否可执行.
而已!
(根据您的真实账户替换reponame,名称空间和用户并享受).
最后一点:如果你想在github上提交你的名字andavatar,请确保你在gitlab上使用的电子邮件地址也是你的github帐户的地址之一.否则你会看到你的gitlab用户名.
mln*_*ncn 29
如果您没有托管自己的GitLab,GitLab.com已直接引入此功能,无需任何解决方法.
https://yourgithubusername:yourgithubpassword@github.com/agaric/guts_discuss_resource.git
-如在评论中指出,这是很多更好securitywise,而不是用你的GitHub的访问令牌这里登录凭证; 我测试时会更新答案. 归档时间: |
|
查看次数: |
24589 次 |
最近记录: |