goenitz/githooks

非常简单的由PHP实现的git钩子

安装: 0

依赖项: 0

建议者: 0

安全: 0

类型:项目

dev-master 2019-01-04 08:35 UTC

This package is not auto-updated.

Last update: 2020-08-05 10:34:55 UTC


README

配置www-data用户

mkdir -p /var/www/.ssh
chown www-data:www-data /var/www/.ssh/ -R
sudo -u www-data ssh-keygen -t rsa -C "xxx@xxx.com"
# paste the public key to git server SSH keys
cat /var/www/.ssh/id_rsa.pub
# test
sudo -u www-data git pull origin master

# make www-data user can run git command
vim /etc/sudoers

# Defaults:git    !authenticate #I don't add this line, but someone need
git ALL=(www-data) ALL

安装

composer create-project goentiz/githooks

编辑config.php,设置路径和命令。需要设置的路径为git服务器路径,例如http://www.xxx.com/path

    'path' => [
        'exec' => 'cd /var/www/platform-web && git pull && yarn && yarn run build',
    ],

就这样。

很简单,没有进行验证。您可以在index.php中添加验证或其他逻辑代码。