.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "CGI::Github::Webhook 3pm" .TH CGI::Github::Webhook 3pm "2021-01-08" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CGI::Github::Webhook \- Easily create CGI based GitHub webhooks .SH "VERSION" .IX Header "VERSION" version 0.06 .SH "SYNOPSIS" .IX Header "SYNOPSIS" CGI::Github::Webhook allows one to easily create simple, CGI-based GitHub webhooks. .PP .Vb 1 \& #!/usr/bin/perl \& \& use CGI::Github::Webhook; \& \& my $ghwh = CGI::Github::Webhook\->new( \& mime_type => \*(Aqtext/plain\*(Aq, \& trigger => \*(Aq/srv/some\-github\-project/bin/deploy.pl\*(Aq, \& trigger_backgrounded => 1, \& secret => \*(Aquse a generated password here, nothing valuable\*(Aq, \& log => \*(Aq/srv/some\-github\-project/log/trigger.log\*(Aq, \& ... \& ); \& $ghwh\->run(); .Ve .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .SS "new" .IX Subsection "new" Constructor. Takes a configuration hash (or array) as parameters. .PP \fIList of parameters for \f(BInew()\fI constructor.\fR .IX Subsection "List of parameters for new() constructor." .PP They can be used as (Moo-style) accessors on the CGI::Github::Webhook object, too. .PP badges_from .IX Subsection "badges_from" .PP Path where to look for badge files. Defaults to File::ShareDir's module_dir. .PP badge_to .IX Subsection "badge_to" .PP Local path to file to which style badges should be written. Defaults to undef which means the feature is disabled. .PP Needs to have a suffix. That suffix will then be used to look for a file in the right format. .PP Currently only \*(L".svg\*(R" and \*(L".png\*(R" suffixes/formats are supported if no custom badge set is used. .PP cgi .IX Subsection "cgi" .PP The \s-1CGI\s0.pm object internally used. .PP log .IX Subsection "log" .PP Where to send the trigger's output to. Defaults to '/dev/stderr', i.e. goes to the web server's error log. Use '/dev/null' to disable. .PP For now it needs to be a path on the file system. Passing file handles objects doesn't work (yet). .PP mime_type .IX Subsection "mime_type" .PP The mime-type used to return the contents. Defaults to 'text/plain; charset=utf\-8' for now. .PP secret .IX Subsection "secret" .PP The shared secret you entered on GitHub as secret for this trigger. Currently required. I recommend to use the output of \&\fBmakepasswd\fR\|(1), \fBapg\fR\|(1), \fBpwgen\fR\|(1) or using Crypt::GeneratePassword to generate a randon and secure shared password. .PP text_on_success .IX Subsection "text_on_success" .PP Text to be returned to GitHub as body if the trigger was successfully (or at least has been spawned successfully). Defaults to \*(L"Successfully triggered\*(R". .PP text_on_auth_fail .IX Subsection "text_on_auth_fail" .PP Text to be returned to GitHub as body if the authentication failed. Defaults to \*(L"Authentication failed\*(R". .PP text_on_trigger_fail .IX Subsection "text_on_trigger_fail" .PP Text to be returned to GitHub as body if spawning the trigger failed. Defaults to \*(L"Trigger failed\*(R". .PP trigger .IX Subsection "trigger" .PP The script or command which should be called when the webhook is called. Required. .PP trigger_backgrounded .IX Subsection "trigger_backgrounded" .PP Boolean attribute controlling if the script or command passed as trigger needs to be started backgrounded (i.e. if it takes longer than a few seconds) or not. Defaults to 1 (i.e. that the trigger script is backgrounded). .SH "OTHER PROPERTIES" .IX Header "OTHER PROPERTIES" authenticated .IX Subsection "authenticated" .PP Returns true if the authentication could be verified and false else. Read-only attribute. .PP payload .IX Subsection "payload" .PP The payload as passed as payload in the \s-1POST\s0 request .PP payload_json .IX Subsection "payload_json" .PP The payload as passed as payload in the \s-1POST\s0 request if it is valid \&\s-1JSON,\s0 else an error message in \s-1JSON\s0 format. .PP payload_perl .IX Subsection "payload_perl" .PP The payload as perl data structure (hashref) as decoded by decode_json. If the payload was no valid \s-1JSON,\s0 it returns a hashref containing either { payload => 'none' } if there was no payload, or { error => ... } in case of a decode_json error had been caught. .SH "SUBROUTINES/METHODS" .IX Header "SUBROUTINES/METHODS" .SS "deploy_badge" .IX Subsection "deploy_badge" Copies file given as parameter to path given via badge_to attribute. The parameter needs to be given without file suffix. The file suffix from the badges attribute will be appended. .PP Doesn't do anything if badge_to is not set. .SS "header" .IX Subsection "header" Passes arguments to and return value from \f(CW$self\fR\->cgi\->\fBheader()\fR, i.e. a shortcut for \f(CW$self\fR\->cgi\->\fBheader()\fR. .PP If no parameters are passed, \f(CW$self\fR\->mime_type is passed. .SS "send_header" .IX Subsection "send_header" Passes arguments to \f(CW$self\fR\->header and prints result to \s-1STDOUT.\s0 .SS "run" .IX Subsection "run" Start the authentication verification and run the trigger if the authentication succeeds. .PP Returns true on success, false on error. More precisely it returns a defined false on error launching the trigger and undef on authentication error. .SH "AUTHOR" .IX Header "AUTHOR" Axel Beckert, \f(CW\*(C`\*(C'\fR .SH "BUGS" .IX Header "BUGS" Please report any bugs, either via via GitHub Issues at or via the \s-1CPAN\s0 Request Tracker by sending an e\-mail to \&\f(CW\*(C`bug\-cgi\-github\-webhook@rt.cpan.org\*(C'\fR or submitting a bug report through the \s-1CPAN\s0 Request Tracker web interface at . .SH "SUPPORT" .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc CGI::Github::Webhook .Ve .PP You can also look for information at: .IP "\(bu" 4 \&\s-1RT: CPAN\s0's request tracker (report bugs here) .Sp .IP "\(bu" 4 AnnoCPAN: Annotated \s-1CPAN\s0 documentation .Sp .IP "\(bu" 4 \&\s-1CPAN\s0 Ratings .Sp .IP "\(bu" 4 Search \s-1CPAN\s0 .Sp .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" Copyright 2016 Axel Beckert. .PP This program is free software; you can redistribute it and/or modify it under the terms of either: the \s-1GNU\s0 General Public License as published by the Free Software Foundation; or the Artistic License. .PP See for more information. .SH "AUTHOR" .IX Header "AUTHOR" Axel Beckert .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2016 by Axel Beckert. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.