From 97f736d3a4b75e6937821cd842e6590acf7f6631 Mon Sep 17 00:00:00 2001 From: Jake Hiller Date: Wed, 24 Jun 2020 09:50:07 -0400 Subject: [PATCH] run build --- lib/comment.js | 11 +++++++++-- lib/main.js | 35 +++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/lib/comment.js b/lib/comment.js index 1fd06d5..43bdb35 100644 --- a/lib/comment.js +++ b/lib/comment.js @@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", { value: true }); +exports.deleteComment = exports.createComment = exports.updateComment = exports.findPreviousComment = void 0; function headerComment(header) { return ``; } @@ -26,9 +27,15 @@ function updateComment(octokit, repo, comment_id, body, header, previousBody) { }); } exports.updateComment = updateComment; -function createComment(octokit, repo, issue_number, body, header) { +function createComment(octokit, repo, issue_number, body, header, previousBody) { return __awaiter(this, void 0, void 0, function* () { - yield octokit.issues.createComment(Object.assign(Object.assign({}, repo), { issue_number, body: `${headerComment(header)}\n${body}` })); + yield octokit.issues.createComment(Object.assign(Object.assign({}, repo), { issue_number, body: previousBody ? `${previousBody}\n${body}` : `${headerComment(header)}\n${body}` })); }); } exports.createComment = createComment; +function deleteComment(octokit, repo, comment_id) { + return __awaiter(this, void 0, void 0, function* () { + yield octokit.issues.deleteComment(Object.assign(Object.assign({}, repo), { comment_id })); + }); +} +exports.deleteComment = deleteComment; diff --git a/lib/main.js b/lib/main.js index 724e15a..33d7274 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,4 +1,23 @@ "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -8,13 +27,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(require("@actions/core")); const github_1 = require("@actions/github"); @@ -35,6 +47,7 @@ function run() { const path = core.getInput("path", { required: false }); const header = core.getInput("header", { required: false }) || ""; const append = core.getInput("append", { required: false }) || false; + const recreate = core.getInput("recreate", { 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); @@ -49,11 +62,13 @@ function run() { body = message; } if (previous) { - if (append) { - yield comment_1.updateComment(octokit, repo, previous.id, body, header, previous.body); + const previousBody = append && previous.body; + if (recreate) { + yield comment_1.deleteComment(octokit, repo, previous.id); + yield comment_1.createComment(octokit, repo, number, body, header, previousBody); } else { - yield comment_1.updateComment(octokit, repo, previous.id, body, header); + yield comment_1.updateComment(octokit, repo, previous.id, body, header, previousBody); } } else {