mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-13 12:11:14 +00:00
run build
This commit is contained in:
parent
1ec19bd242
commit
97f736d3a4
2 changed files with 34 additions and 12 deletions
|
|
@ -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 `<!-- Sticky Pull Request Comment${header} -->`;
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
35
lib/main.js
35
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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue