How can I deploy code using webhook on github?

Source: Internet
Author: User
Tags call shell webhook
PHP is used to process requests sent from github. The test is normal. It is always unsuccessful to call a script or execute a command using exec. {Code...} file_put_contents can write content, proving that the signature is matched successfully. The pull code can also be executed independently on the server. Scripts... Use PHP to process requests sent from github. The test is normal. It is always unsuccessful to call a script or execute a command using exec.

// Determine whether the signature matches if ($ hash = $ payloadHash) {// call shell // file_put_contents ('/var/www/niucunhui. io/auto/test.txt ', 'The program is here'); exec ('CD/var/www/niucunhui. io/auto/& git pull ');}

File_put_contents can write content to prove that the signature is matched successfully. The pull code can also be executed independently on the server.

The script is as follows:

#!/bin/bashWEB_PATH='/var/www/niucunhui.io/sql-optimize-referance/'WEB_USER='www'WEB_USERGROUP='www'echo "Start deployment"cd $WEB_PATHecho "pulling source code..."git reset --hard origin/mastergit clean -fgit pullgit checkout masterecho "changing permissions..."chown -R $WEB_USER:$WEB_USERGROUP $WEB_PATHecho "Finished."

You can also run the exec () command to write a PHP program separately.

Is there a problem?
Server version: CentOS 6.5
PHP version 5.6.15

Reply content:

PHP is used to process requests sent from github. The test is normal. It is always unsuccessful to call a script or execute a command using exec.

// Determine whether the signature matches if ($ hash = $ payloadHash) {// call shell // file_put_contents ('/var/www/niucunhui. io/auto/test.txt ', 'The program is here'); exec ('CD/var/www/niucunhui. io/auto/& git pull ');}

File_put_contents can write content to prove that the signature is matched successfully. The pull code can also be executed independently on the server.

The script is as follows:

#!/bin/bashWEB_PATH='/var/www/niucunhui.io/sql-optimize-referance/'WEB_USER='www'WEB_USERGROUP='www'echo "Start deployment"cd $WEB_PATHecho "pulling source code..."git reset --hard origin/mastergit clean -fgit pullgit checkout masterecho "changing permissions..."chown -R $WEB_USER:$WEB_USERGROUP $WEB_PATHecho "Finished."

You can also run the exec () command to write a PHP program separately.

Is there a problem?
Server version: CentOS 6.5
PHP version 5.6.15

Https://zhuzhenyu.org/2016/01/03/php-github-php/

The git command must be fully written.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.