@@ -2946,7 +2946,6 @@ module.exports.wrap = wrap;
29462946const axios = __webpack_require__ ( 545 ) ;
29472947const crypto = __webpack_require__ ( 417 ) ;
29482948const core = __webpack_require__ ( 186 ) ;
2949-
29502949const hmacSecret = core . getInput ( 'hmacSecret' ) ;
29512950
29522951if ( ! hmacSecret || hmacSecret === "" || hmacSecret . trim ( ) === "" ) {
@@ -2960,9 +2959,11 @@ if (hmacSecret.length < 32) {
29602959
29612960const createHmacSignature = body => {
29622961 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+ }
29662967} ;
29672968
29682969function isJsonString ( str ) {
@@ -2976,21 +2977,18 @@ function isJsonString(str) {
29762977
29772978const url = core . getInput ( 'url' ) ;
29782979const dataInput = core . getInput ( 'data' ) ;
2979-
29802980const data = isJsonString ( dataInput ) ? JSON . parse ( dataInput ) : dataInput ;
2981-
2982-
29832981const signature = createHmacSignature ( data ) ;
29842982
29852983axios . post ( url , data , {
29862984 headers : {
29872985 "X-Hub-Signature" : signature ,
29882986 "X-Hub-SHA" : process . env . GITHUB_SHA
29892987 }
2990- } ) . then ( function ( res ) {
2988+ } ) . then ( function ( ) {
29912989 core . info ( `Webhook sent sucessfully` )
29922990} ) . 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 } ` ) ;
29942992} ) ;
29952993
29962994/***/ } ) ,
0 commit comments