@@ -9685,6 +9685,7 @@ var __webpack_exports__ = {};
96859685// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
96869686(() => {
96879687const { inspect } = __nccwpck_require__(3837);
9688+ const { readFileSync, existsSync } = __nccwpck_require__(7147);
96889689const core = __nccwpck_require__(2186);
96899690const github = __nccwpck_require__(5438);
96909691
@@ -9757,6 +9758,8 @@ async function run() {
97579758 issueNumber: core.getInput("issue-number"),
97589759 commentId: core.getInput("comment-id"),
97599760 body: core.getInput("body"),
9761+ file: core.getInput("file"),
9762+ fileEncoding: core.getInput("file-encoding") || 'utf8',
97609763 editMode: core.getInput("edit-mode"),
97619764 reactions: core.getInput("reactions")
97629765 ? core.getInput("reactions")
@@ -9777,16 +9780,30 @@ async function run() {
97779780 return;
97789781 }
97799782
9783+ if (inputs.file && inputs.body) {
9784+ core.setFailed("Only one of 'file' or 'body' can be set.");
9785+ return;
9786+ }
9787+
9788+ if (inputs.file) {
9789+ if (!existsSync(inputs.file)) {
9790+ core.setFailed(`File '${inputs.file}' does not exist.`);
9791+ return;
9792+ }
9793+ }
9794+
97809795 const octokit = github.getOctokit(inputs.token);
97819796
97829797 if (inputs.commentId) {
97839798 // Edit a comment
9784- if (!inputs.body && !inputs.reactions) {
9785- core.setFailed("Missing either comment 'body' or 'reactions'.");
9799+ if (!inputs.body && !inputs.reactions && !inputs.file ) {
9800+ core.setFailed("Missing either comment 'body', 'file', or 'reactions'.");
97869801 return;
97879802 }
97889803
9789- if (inputs.body) {
9804+ const body = getBodyOrFile(inputs);
9805+
9806+ if (body) {
97909807 var commentBody = "";
97919808 if (editMode == "append") {
97929809 // Get the comment body
@@ -9798,7 +9815,7 @@ async function run() {
97989815 commentBody = comment.body + "\n";
97999816 }
98009817
9801- commentBody = commentBody + inputs. body;
9818+ commentBody = commentBody + body;
98029819 core.debug(`Comment body: ${commentBody}`);
98039820 await octokit.rest.issues.updateComment({
98049821 owner: repo[0],
@@ -9816,15 +9833,18 @@ async function run() {
98169833 }
98179834 } else if (inputs.issueNumber) {
98189835 // Create a comment
9819- if (!inputs.body) {
9820- core.setFailed("Missing comment 'body'.");
9836+ const body = getBodyOrFile(inputs);
9837+
9838+ if (!body) {
9839+ core.setFailed("Missing comment 'body' or 'file'.");
98219840 return;
98229841 }
9842+
98239843 const { data: comment } = await octokit.rest.issues.createComment({
98249844 owner: repo[0],
98259845 repo: repo[1],
98269846 issue_number: inputs.issueNumber,
9827- body: inputs.body ,
9847+ body,
98289848 });
98299849 core.info(
98309850 `Created comment id '${comment.id}' on issue '${inputs.issueNumber}'.`
@@ -9848,6 +9868,14 @@ async function run() {
98489868 }
98499869}
98509870
9871+ function getBodyOrFile (inputs) {
9872+ if (inputs.body) {
9873+ return inputs.body;
9874+ } else if (inputs.file) {
9875+ return readFileSync(inputs.file, inputs.fileEncoding);
9876+ }
9877+ }
9878+
98519879run();
98529880
98539881})();
0 commit comments