From e9aad93807636a3049e4c55c7228e66b120157ff Mon Sep 17 00:00:00 2001 From: Simon Stender Boisen Date: Thu, 26 Mar 2020 14:36:36 +0100 Subject: [PATCH] release v1.4.0 --- lib/comment.js | 4 ++-- lib/main.js | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/comment.js b/lib/comment.js index 2e4aabb..1fd06d5 100644 --- a/lib/comment.js +++ b/lib/comment.js @@ -20,9 +20,9 @@ function findPreviousComment(octokit, repo, issue_number, header) { }); } exports.findPreviousComment = findPreviousComment; -function updateComment(octokit, repo, comment_id, body, header) { +function updateComment(octokit, repo, comment_id, body, header, previousBody) { return __awaiter(this, void 0, void 0, function* () { - yield octokit.issues.updateComment(Object.assign(Object.assign({}, repo), { comment_id, body: `${headerComment(header)}\n${body}` })); + yield octokit.issues.updateComment(Object.assign(Object.assign({}, repo), { comment_id, body: previousBody ? `${previousBody}\n${body}` : `${headerComment(header)}\n${body}` })); }); } exports.updateComment = updateComment; diff --git a/lib/main.js b/lib/main.js index 913c4aa..79facda 100644 --- a/lib/main.js +++ b/lib/main.js @@ -20,9 +20,9 @@ const core = __importStar(require("@actions/core")); const github_1 = require("@actions/github"); const comment_1 = require("./comment"); function run() { - var _a, _b, _c; + var _a, _b; return __awaiter(this, void 0, void 0, function* () { - const number = ((_c = (_b = (_a = github_1.context) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.pull_request) === null || _c === void 0 ? void 0 : _c.number) || + const number = ((_b = (_a = github_1.context === null || github_1.context === void 0 ? void 0 : github_1.context.payload) === null || _a === void 0 ? void 0 : _a.pull_request) === null || _b === void 0 ? void 0 : _b.number) || +core.getInput("number", { required: false }); if (isNaN(number) || number < 1) { core.info("no numbers given: skip step"); @@ -32,11 +32,17 @@ function run() { const repo = github_1.context.repo; const body = core.getInput("message", { required: true }); const header = core.getInput("header", { required: false }) || ""; + const append = core.getInput("append", { required: false }) || false; const githubToken = core.getInput("GITHUB_TOKEN", { required: true }); const octokit = new github_1.GitHub(githubToken); const previous = yield comment_1.findPreviousComment(octokit, repo, number, header); if (previous) { - yield comment_1.updateComment(octokit, repo, previous.id, body, header); + if (append) { + yield comment_1.updateComment(octokit, repo, previous.id, body, header, previous.body); + } + else { + yield comment_1.updateComment(octokit, repo, previous.id, body, header); + } } else { yield comment_1.createComment(octokit, repo, number, body, header);