git的钩子实现 ##Configuration 修改config.php
$_config_data["test"] 每一组都是一个站点,你可以多加几个站点
比如
$_config_data["new"] = array();
$_config_data["new"]["access_token"] = "secret-token";//密钥
$_config_data["new"]["access_ip"] = array("192.168.2.18");//允许ip
$_config_data["new"]["dir"] = "/home/wwwys/test/webhook/";//目录必填
$_config_data["new"]["git_url"] = "git@192.168.2.18:czw/test.git";//git地址
$_config_data["new"]["sh_clone"] = "git clone {$_config_data["test"]["git_url"]} {$_config_data["test"]["dir"]}";//git clone 命令 初次发布必填
$_config_data["new"]["sh_pull"] = "cd {$_config_data["test"]["dir"]} && /usr/bin/git pull"; //git pull 命令 更新代码必填
###web server open_basedir路径相对于需要发布的项目路径更高一级,不然php无法判断跨范围文件是否存在
##On GitHub | GitLab | Bitbucket
In your repository, navigate to Settings → Webhooks → Add webhook, and use the following settings:
- Payload URL: https://www.yoursite.com/webhook/index.php?k=new
- k 参数是你配置的数组key值
- Content type: application/json
- Secret: The value of TOKEN in config.php
- Which events would you like to trigger this webhook?: 🔘 Just the push event
- Active: ☑️
Click "Add webhook" to save your settings, and the script should start working.
In your repository, navigate to Settings → Integrations, and use the following settings:
- URL: https://www.yoursite.com/webhook/index.php?k=new
- k 参数是你配置的数组key值
- Secret Token: The value of TOKEN in config.php
- Trigger: ☑️ Push events
- Enable SSL verification: ☑️ (only if using SSL, see GitLab's documentation for more details)
Click "Add webhook" to save your settings, and the script should start working.
In your repository, navigate to Settings → Webhooks → Add webhook, and use the following settings:
- Title: git-deploy
- URL: https://www.yoursite.com/webhook/index.php?token=secret-token&k=new
- k 参数是你配置的数组key值
- Active: ☑️
- SSL / TLS: ⬜ Skip certificate verification (only if using SSL, see Bitbucket's documentation for more details)
- Triggers: 🔘 Repository push
Click "Save" to save your settings, and the script should start working.