From a976623266fb03728260ebcbff18fa0335498b1e Mon Sep 17 00:00:00 2001 From: Joel Male Date: Thu, 28 Mar 2024 12:51:03 +1000 Subject: [PATCH] feat: fix syntax error --- dist/index.js | 5 +++-- dist/main.js | 5 +++-- dist/main.js.map | 2 +- src/main.ts | 6 ++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dist/index.js b/dist/index.js index 44cff8ed..e47533a5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -76,8 +76,9 @@ function run() { : process.env.insecure ? process.env.insecure == 'true' : false; - if (process.env.github_event && body) { - const decodedBody = JSON.parse(body); + const githubEvent = core.getInput('github_event') == 'true'; + if (githubEvent) { + const decodedBody = JSON.parse(body || '{}'); decodedBody.github_event = github_1.context; body = JSON.stringify(decodedBody); } diff --git a/dist/main.js b/dist/main.js index a602446a..dcffd733 100644 --- a/dist/main.js +++ b/dist/main.js @@ -34,8 +34,9 @@ function run() { : process.env.insecure ? process.env.insecure == 'true' : false; - if (process.env.github_event && body) { - const decodedBody = JSON.parse(body); + const githubEvent = core.getInput('github_event') == 'true'; + if (githubEvent) { + const decodedBody = JSON.parse(body || '{}'); decodedBody.github_event = github_1.context; body = JSON.stringify(decodedBody); } diff --git a/dist/main.js.map b/dist/main.js.map index 45f107e3..c5795307 100644 --- a/dist/main.js.map +++ b/dist/main.js.map @@ -1 +1 @@ -{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAqC;AACrC,iCAA2B;AAC3B,4CAAuC;AAEvC,SAAe,GAAG;;QAChB,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC9B,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YACtB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW;gBACvB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW;gBACzB,CAAC,CAAC,EAAE,CAAA;QAER,MA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AG,EAAE,CAAC;gBAEtB,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;gBACjB,OAAM;YACR,CAAC;QACH,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,CAAC,EAAE;YACX,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC,CAAA;YAC1B,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACjB,OAAM;QACR,CAAC,CAAC,CAAA;IACN,CAAC;CAAA;AAED,SAAS,KAAK,CAAC,UAAU;IAEvB,IAAI,CAAC,SAAS,CAAC,yBAAyB,UAAU,EAAE,CAAC,CAAA;IAErD,MAAM,IAAI,KAAK,CAAC,oCAAoC,UAAU,EAAE,CAAC,CAAA;AACnE,CAAC;AAED,GAAG,EAAE,CAAA"} \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 7583d610..f1aa6e26 100644 --- a/src/main.ts +++ b/src/main.ts @@ -27,10 +27,12 @@ async function run() { ? process.env.insecure == 'true' : false + const githubEvent = core.getInput('github_event') == 'true' + // if github_event is set to true, append it to the body - if (process.env.github_event && body) { + if (githubEvent) { // decode the body - const decodedBody = JSON.parse(body) + const decodedBody = JSON.parse(body || '{}') // set the github event decodedBody.github_event = context