git webhook 代码自动部署

1.如何生成ssh公钥

你可以按如下命令来生成sshkey,如果运行php-fpm的用户是www,必须切换到www用户修改/etc/passwd/的wwwwww:x:501:501::/home/www:/bin/bash 使www用户可登录,su www切换用户然后生成sshkey

root@locahost#:ssh-keygen -t rsa -C "[email protected]"   ##邮箱随便填写 Creates a new ssh key using the provided email
# Generating public/private rsa key pair...

查看你的公钥key,并把他添加到 Git @ OSC http://git.oschina.net/ 项目下


cat ~/.ssh/id_rsa.pub
# ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc....

git webhook 代码自动部署_第1张图片

添加后,在终端(Terminal)中输入

ssh -T git@git.oschina.net

若返回

Welcome to Git@OSC, yourname!

则证明添加成功。

增加webhooks,让代码在提交推送时自动更新到测试环境
git webhook 代码自动部署_第2张图片


  $post=json_decode($_POST['hook'],true);
                if($post['password']==123456){
                  echo exec("cd /data/airenwen/ && /usr/local/git/bin/git pull");
                 }

你可能感兴趣的:(其它)