Created
September 24, 2013 22:22
-
-
Save grapeot/6692145 to your computer and use it in GitHub Desktop.
A php script to send auto email notifications when a github repo is pushed. More details available at http://grapeot.me/automatic-email-notification-on-github-pushes.html.
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
<? | |
$r = 'This is an automatically generated message notifying you that someone pushed new commits to the github repo <project>.' . " Don't forget to do git pull before your editing.\r\n\r\nEdit summary: \r\n"; | |
$payload = $_REQUEST['payload']; | |
preg_match_all('@"name":"([\w ]*?)","email@', $payload, $matches); | |
$authors = $matches[1]; | |
preg_match_all('@"message":"([^"]*)"@', $payload, $matches); | |
$messages = $matches[1]; | |
preg_match_all('@"url":"([^"]*)"@', $payload, $matches); | |
$links= $matches[1]; | |
for ($i = 0; $i < count($messages) - 1; ++$i) | |
$r = $r . $authors[$i] . ' committed with message "' . $messages[$i] . '" at ' . $links[$i] . "\r\n"; | |
mail('<receipts>', 'New commits pushed to <project>', $r, 'From: <email>' . "\r\n" . 'Reply-to: <email>' . "\r\n"); | |
echo $r; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment