adamcooke / growler

A simple codebase/github post-receive script to send a growl notification for each commit to a group of networked machines whenever a push is received.

This URL has Read+Write access

growler / growler.php
100644 36 lines (27 sloc) 0.888 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/*
* Growler Post-Receive Hook
*
* Dependency: mumbles - http://www.mumbles-project.org
*
* - Install this script onto a web server and setup a post-receive hook within
* codebase/github to call the script - http://myinternalserver.domain.com/growler.php.
*
* - Assign the IP addresses of the machines which should receive your growl whenever
* a push is received by codebase into the $ips array below.
*
*/
 
$ips = Array('10.0.0.1', '10.0.0.2', '10.0.0.3');
 
$data = stripslashes($_POST['payload']);
$payload = json_decode($data);
 
$repository = $payload->repository->name;
 
foreach($payload->commits as $commit) {
 
  $author = $commit->author->name;
  $commit_message = $commit->message;
 
  $title = "$author committed";
  $message = "to $repository\n\n$commit_message";
 
  foreach($ips as $ip) {
    system("mumbles-send -g $ip '$title' '$message'");
  }
 
}
 
?>