Skip to content

Instantly share code, notes, and snippets.

@normanlolx
Forked from cowboy/github_post_recieve.php
Last active November 6, 2018 14:43
Show Gist options
  • Select an option

  • Save normanlolx/91411e5494f5e04e000a7cf28df95447 to your computer and use it in GitHub Desktop.

Select an option

Save normanlolx/91411e5494f5e04e000a7cf28df95447 to your computer and use it in GitHub Desktop.

Revisions

  1. Norman Kämper-Leymann revised this gist Jul 3, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions webhook.php
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@
    if ( isset($_POST['payload']) && $_POST['payload'] ) {
    echo shell_exec('cd /var/www/mydrupal/ && sudo -u myuser git pull');
    echo shell_exec('cd /var/www/mydrupal/sites/all/themes/mytheme/ && sudo -u myuser node ./node_modules/gulp/bin/gulp.js mygulptask');
    // Adding the drush will cause the delivery being displayed as unsuccessful. Means GitHub doesn't wait so long. The command will run nevertheless.
    echo shell_exec('cd /var/www/mydrupal/ && sudo -u myuser drush @sites cc all -y');
    }

  2. Norman Kämper-Leymann revised this gist Jul 3, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions webhook.php
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@
    if ( isset($_POST['payload']) && $_POST['payload'] ) {
    echo shell_exec('cd /var/www/mydrupal/ && sudo -u myuser git pull');
    echo shell_exec('cd /var/www/mydrupal/sites/all/themes/mytheme/ && sudo -u myuser node ./node_modules/gulp/bin/gulp.js mygulptask');
    echo shell_exec('cd /var/www/mydrupal/ && sudo -u myuser drush @sites cc all -y');
    }

    // Should return www-data
  3. Norman Kämper-Leymann revised this gist Jul 3, 2017. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions webhook.php
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,10 @@
    echo shell_exec('cd /var/www/mydrupal/ && sudo -u myuser git pull');
    echo shell_exec('cd /var/www/mydrupal/sites/all/themes/mytheme/ && sudo -u myuser node ./node_modules/gulp/bin/gulp.js mygulptask');
    }
    // echo shell_exec('whoami');
    // echo shell_exec('sudo -u apc whoami');

    // Should return www-data
    echo shell_exec('whoami');
    // Should return myuser
    echo shell_exec('sudo -u myuser whoami');

    ?>
  4. Norman Kämper-Leymann revised this gist Jul 3, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions webhook.php
    Original file line number Diff line number Diff line change
    @@ -4,5 +4,7 @@
    echo shell_exec('cd /var/www/mydrupal/ && sudo -u myuser git pull');
    echo shell_exec('cd /var/www/mydrupal/sites/all/themes/mytheme/ && sudo -u myuser node ./node_modules/gulp/bin/gulp.js mygulptask');
    }
    // echo shell_exec('whoami');
    // echo shell_exec('sudo -u apc whoami');

    ?>
  5. Norman Kämper-Leymann renamed this gist Jul 3, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. Norman Kämper-Leymann revised this gist Jul 3, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pull.php
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,4 @@
    echo shell_exec('cd /var/www/mydrupal/sites/all/themes/mytheme/ && sudo -u myuser node ./node_modules/gulp/bin/gulp.js mygulptask');
    }

    ?>hi
    ?>
  7. Norman Kämper-Leymann revised this gist Jul 3, 2017. No changes.
  8. Norman Kämper-Leymann revised this gist Jul 3, 2017. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions pull.php
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    <?php

    if ( $_POST['payload'] ) {
    echo shell_exec( 'git pull' );
    if ( isset($_POST['payload']) && $_POST['payload'] ) {
    echo shell_exec('cd /var/www/mydrupal/ && sudo -u myuser git pull');
    echo shell_exec('cd /var/www/mydrupal/sites/all/themes/mytheme/ && sudo -u myuser node ./node_modules/gulp/bin/gulp.js mygulptask');
    }

    ?>hi
  9. Norman Kämper-Leymann revised this gist Jul 3, 2017. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions pull.php
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,5 @@
    <?php

    // Use in the "Post-Receive URLs" section of your GitHub repo.

    if ( $_POST['payload'] ) {
    echo shell_exec( 'git pull' );
    }
  10. Norman Kämper-Leymann revised this gist Jul 3, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pull.php
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    // Use in the "Post-Receive URLs" section of your GitHub repo.

    if ( $_POST['payload'] ) {
    shell_exec( 'cd /srv/www/git-repo/ && git reset --hard HEAD && git pull' );
    echo shell_exec( 'git pull' );
    }

    ?>hi
  11. Norman Kämper-Leymann revised this gist Jul 3, 2017. No changes.
  12. Norman Kämper-Leymann renamed this gist Jul 3, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  13. @cowboy cowboy created this gist Oct 11, 2010.
    9 changes: 9 additions & 0 deletions github_post_recieve.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    <?php

    // Use in the "Post-Receive URLs" section of your GitHub repo.

    if ( $_POST['payload'] ) {
    shell_exec( 'cd /srv/www/git-repo/ && git reset --hard HEAD && git pull' );
    }

    ?>hi