Skip to content

Instantly share code, notes, and snippets.

@misterhon
Last active August 29, 2015 14:16
Show Gist options
  • Save misterhon/cfbd87bde3e949353fae to your computer and use it in GitHub Desktop.
Save misterhon/cfbd87bde3e949353fae to your computer and use it in GitHub Desktop.
Webhook scirpt v.1
<?php
/**
* This script pulls updates from repo and copies to the public directory
**/
$output = `cd ~/repo_dir && git pull && cp -r ~/repo_dir/* ~/public_html`;
if ( $output ) {
$to = 'your@email.com';
$subject = 'Webhook Executed';
$subject = 'GitHub Webhook Executed';
$headers = "From: webmaster@your-domain.com" . "\r\n" .
'Reply-To: webmaster@your-domain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
// The script was executed. Tell someone.
mail($to, $subject, $output, $headers);
// Display the same message in Github Webhook response.
die( $output );
}
die("Git pull didn't run. Wrong repo directory?");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment