Questions about GitHub using Webhook to deploy code?

Source: Internet
Author: User
Using PHP to handle requests sent by GitHub, the test is normal. Executing commands in the call script or using EXEC () is always unsuccessful.

// 判断签名是否匹配if ($hash === $payloadHash) {    // 调用shell    // file_put_contents('/var/www/niucunhui.io/auto/test.txt', '程序走到这里了');    exec('cd /var/www/niucunhui.io/auto/ && git pull');}

File_put_contents can write to the content to prove that the signature was successfully matched. It is also possible to pull code when the server executes the script separately.

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."

It is also possible to write a single PHP program exec () command.

Excuse me, is it possible that there is a problem?
Server version CentOS 6.5
PHP version 5.6.15

Reply content:

Using PHP to handle requests sent by GitHub, the test is normal. Executing commands in the call script or using EXEC () is always unsuccessful.

// 判断签名是否匹配if ($hash === $payloadHash) {    // 调用shell    // file_put_contents('/var/www/niucunhui.io/auto/test.txt', '程序走到这里了');    exec('cd /var/www/niucunhui.io/auto/ && git pull');}

File_put_contents can write to the content to prove that the signature was successfully matched. It is also possible to pull code when the server executes the script separately.

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."

It is also possible to write a single PHP program exec () command.

Excuse me, is it possible that there is a problem?
Server version CentOS 6.5
PHP version 5.6.15

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

git commands need to write full path

  • 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.