diff --git a/src/utils.js b/src/utils.js index 74e6d1e..55d9223 100644 --- a/src/utils.js +++ b/src/utils.js @@ -57,21 +57,25 @@ function getFields () { * @returns {headRef: string; headhSha: string; baseRef: string; baseSha: string; issueUrl: string; htmlUrl: string; prTitle: string; senderAvatarUrl: string; senderHtmlUrl: string;} */ function getGhaEventData (eventFilePath, isGha) { - if (!eventFilePath || !isGha) { - return - } + try { + if (!eventFilePath || !isGha) { + return + } - const data = JSON.parse(fs.readFileSync(eventFilePath)) - return { - headRef: data.pull_request.head.ref, - headhSha: data.pull_request.head.sha, - baseRef: data.pull_request.base.ref, - baseSha: data.pull_request.base.sha, - issueUrl: data.pull_request.issue_url, - htmlUrl: data.pull_request.html_url, - prTitle: data.pull_request.title, - senderAvatarUrl: data.sender.avatar_url, - senderHtmlUrl: data.sender.html_url + const data = JSON.parse(fs.readFileSync(eventFilePath)) + return { + headRef: data.pull_request.head.ref, + headhSha: data.pull_request.head.sha, + baseRef: data.pull_request.base.ref, + baseSha: data.pull_request.base.sha, + issueUrl: data.pull_request.issue_url, + htmlUrl: data.pull_request.html_url, + prTitle: data.pull_request.title, + senderAvatarUrl: data.sender.avatar_url, + senderHtmlUrl: data.sender.html_url + } + } catch (e) { + console.debug('[GHA Data Error]: ', e) } }