@@ -2946,7 +2946,6 @@ module.exports.wrap = wrap;
2946
2946
const axios = __webpack_require__ ( 545 ) ;
2947
2947
const crypto = __webpack_require__ ( 417 ) ;
2948
2948
const core = __webpack_require__ ( 186 ) ;
2949
-
2950
2949
const hmacSecret = core . getInput ( 'hmacSecret' ) ;
2951
2950
2952
2951
if ( ! hmacSecret || hmacSecret === "" || hmacSecret . trim ( ) === "" ) {
@@ -2960,9 +2959,11 @@ if (hmacSecret.length < 32) {
2960
2959
2961
2960
const createHmacSignature = body => {
2962
2961
const hmac = crypto . createHmac ( "sha256" , hmacSecret ) ;
2963
- const bodySignature = hmac . update ( JSON . stringify ( body ) ) . digest ( "hex" ) ;
2964
-
2965
- return `${ bodySignature } ` ;
2962
+ if ( body === "" ) {
2963
+ return hmac . digest ( "hex" ) ;
2964
+ } else {
2965
+ return hmac . update ( JSON . stringify ( body ) ) . digest ( "hex" ) ;
2966
+ }
2966
2967
} ;
2967
2968
2968
2969
function isJsonString ( str ) {
@@ -2976,21 +2977,18 @@ function isJsonString(str) {
2976
2977
2977
2978
const url = core . getInput ( 'url' ) ;
2978
2979
const dataInput = core . getInput ( 'data' ) ;
2979
-
2980
2980
const data = isJsonString ( dataInput ) ? JSON . parse ( dataInput ) : dataInput ;
2981
-
2982
-
2983
2981
const signature = createHmacSignature ( data ) ;
2984
2982
2985
2983
axios . post ( url , data , {
2986
2984
headers : {
2987
2985
"X-Hub-Signature" : signature ,
2988
2986
"X-Hub-SHA" : process . env . GITHUB_SHA
2989
2987
}
2990
- } ) . then ( function ( res ) {
2988
+ } ) . then ( function ( ) {
2991
2989
core . info ( `Webhook sent sucessfully` )
2992
2990
} ) . catch ( function ( error ) {
2993
- core . setFailed ( `Request failed with status code ${ error . response . status } ! ` ) ;
2991
+ core . setFailed ( `Request failed with status code ${ error . response . status } ` ) ;
2994
2992
} ) ;
2995
2993
2996
2994
/***/ } ) ,
0 commit comments