Cause: Often local push to gitee and other online code warehouse, and then log on to the server in the pull, very troublesome, want to lazy how to do? Use Git's webhook to implement!1. Implementation Principle 1.1 Local commit push 1.2 online warehouse monitoring push action, that is, Webhook, Callback URL triggers the pull operation of the server 1.3 server pull Operation 2. Implement step 2.1 local and server install Git (skip) 2.2 yards cloud into the project--management->webhook settings (other principles like git,coding)
URL is the address that you can access on the server, the address is the file for pull command, can be php,python,node and so on, tick push is when the push action trigger this URL, access to the server for the pull operation, tick other is the other action, There is no explanation here. After adding, there will be Test button, suggest code write on test
1 shell_exec (' ls ')
If the file directory is returned, it means that the permission can be executed, the server is LNMP, and then only one line of code (my requirement is automatic pull, all do not do in-depth operations, such as validation, logs, classifications, etc. can be supplemented by their own) through the code can view the callback information, according to information operation
$request = Json_decode (file_get_contentstrue)
Pull action
Echo shell_exec (' CD Your_path && git Pull ')
3. Some pits, if unsuccessful, suggest
LL command to check the user permissions generally PHP is a www-data user, using
chown -r:www-chmod -R g+w Your_path
The main problem is permissions, so it should be OK! Routing something yourself to get it done! Then you can have a happy local push server to pull the ~ hahaha
Git----use Webhook for automatic code deployment