Created
February 9, 2012 17:18
-
-
Save toke/1781347 to your computer and use it in GitHub Desktop.
Dancer github webhook receiver. More Info on: http://toke.de/blog/2012/02/09/how-i-post/ now has an own repo https://github.com/toke/dancing-github-webhooks
This file contains hidden or 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
package receivehook; | |
use Dancer ':syntax'; | |
our $VERSION = '0.3'; | |
# Configuration for different projects | |
my $config = { | |
"PROJECTNAME" => { | |
run => "/home/user/bin/updateblog.sh", | |
}, | |
}; | |
prefix '/notify'; | |
get '/*' => sub { | |
header 'Allow' => 'POST'; | |
status '405'; | |
"Not for you\n"; | |
}; | |
post '/:project' => sub { | |
if (not defined $config->{params->{project}}) { | |
status 'not_found'; | |
return "No such project: ".params->{project}."\n"; | |
} | |
my $payload = params->{'payload'}; | |
if (not defined $payload) { | |
status '415'; | |
return "I need a payload\n"; | |
} | |
# Read the configuration for that repo | |
my $repo_config = $config->{$repo->{name}}; | |
if (defined $repo_config && defined $repo_config->{run}) { | |
eval { | |
system $repo_config->{run}; | |
}; | |
} | |
return "OK"; | |
}; | |
true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can now be found in an own repository: https://github.com/toke/dancing-github-webhooks