Skip to content

Instantly share code, notes, and snippets.

@leymannx
Forked from cowboy/github_post_recieve.php
Last active November 6, 2018 14:43
Show Gist options
  • Save leymannx/91411e5494f5e04e000a7cf28df95447 to your computer and use it in GitHub Desktop.
Save leymannx/91411e5494f5e04e000a7cf28df95447 to your computer and use it in GitHub Desktop.
PHP webhook to pull and Gulp build automatically after push
<?php
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');
}
// Should return www-data
echo shell_exec('whoami');
// Should return myuser
echo shell_exec('sudo -u myuser whoami');
?>
@adibnoh
Copy link

adibnoh commented Nov 6, 2018

Thanks man! this works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment