Last active
August 29, 2015 14:16
-
-
Save misterhon/cfbd87bde3e949353fae to your computer and use it in GitHub Desktop.
Webhook scirpt v.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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