Last active
May 24, 2022 08:54
-
-
Save masartz/f1d061c521126c5f72135c47034129d7 to your computer and use it in GitHub Desktop.
For Github webhook payload URL
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
use strict; | |
use warnings; | |
use utf8; | |
use Plack::Request; | |
use HTTP::Entity::Parser; | |
use Hash::MultiValue; | |
use JSON; | |
use Data::Dumper; | |
my $parser = HTTP::Entity::Parser->new; | |
$parser->register('application/x-www-form-urlencoded','HTTP::Entity::Parser::UrlEncoded'); | |
sub { | |
my $env = shift; | |
my ( $params, $uploads) = $parser->parse($env); | |
my $body_parameters = Hash::MultiValue->new(@$params); | |
my $data = JSON::decode_json($body_parameters->{payload} ); | |
#return ["200", ["Content-Type" => "text/plain"], [Dumper($data)]]; | |
my $ret = sprintf("name: %s, PR number: %d, Base branch:%s, merged_at: %s", | |
$data->{repository}->{name}, | |
$data->{pull_request}->{number}, | |
$data->{pull_request}->{base}->{ref}, | |
$data->{pull_request}->{merged_at} | |
); | |
return ["200", ["Content-Type" => "text/plain"], [$ret]]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment