mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-14 20:41:15 +00:00
🔧 Update ts config
This commit is contained in:
parent
67d0dec7b0
commit
0dbe58c83e
5 changed files with 160 additions and 189 deletions
316
dist/index.js
generated
vendored
316
dist/index.js
generated
vendored
|
|
@ -39,15 +39,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
||||||
return result;
|
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) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.findPreviousComment = findPreviousComment;
|
exports.findPreviousComment = findPreviousComment;
|
||||||
exports.updateComment = updateComment;
|
exports.updateComment = updateComment;
|
||||||
|
|
@ -66,14 +57,12 @@ function bodyWithHeader(body, header) {
|
||||||
function bodyWithoutHeader(body, header) {
|
function bodyWithoutHeader(body, header) {
|
||||||
return body.replace(`\n${headerComment(header)}`, "");
|
return body.replace(`\n${headerComment(header)}`, "");
|
||||||
}
|
}
|
||||||
function findPreviousComment(octokit, repo, number, header) {
|
async function findPreviousComment(octokit, repo, number, header) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
let after = null;
|
||||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
let hasNextPage = true;
|
||||||
let after = null;
|
const h = headerComment(header);
|
||||||
let hasNextPage = true;
|
while (hasNextPage) {
|
||||||
const h = headerComment(header);
|
const data = await octokit.graphql(`
|
||||||
while (hasNextPage) {
|
|
||||||
const data = yield octokit.graphql(`
|
|
||||||
query($repo: String! $owner: String! $number: Int! $after: String) {
|
query($repo: String! $owner: String! $number: Int! $after: String) {
|
||||||
viewer { login }
|
viewer { login }
|
||||||
repository(name: $repo owner: $owner) {
|
repository(name: $repo owner: $owner) {
|
||||||
|
|
@ -95,32 +84,27 @@ function findPreviousComment(octokit, repo, number, header) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, Object.assign(Object.assign({}, repo), { after, number }));
|
`, { ...repo, after, number });
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||||
const viewer = data.viewer;
|
const viewer = data.viewer;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||||
const repository = data.repository;
|
const repository = data.repository;
|
||||||
const target = (_c = (_b = (_a = repository.pullRequest) === null || _a === void 0 ? void 0 : _a.comments) === null || _b === void 0 ? void 0 : _b.nodes) === null || _c === void 0 ? void 0 : _c.find((node) => {
|
const target = repository.pullRequest?.comments?.nodes?.find((node) => node?.author?.login === viewer.login.replace("[bot]", "") &&
|
||||||
var _a, _b;
|
!node?.isMinimized &&
|
||||||
return ((_a = node === null || node === void 0 ? void 0 : node.author) === null || _a === void 0 ? void 0 : _a.login) === viewer.login.replace("[bot]", "") &&
|
node?.body?.includes(h));
|
||||||
!(node === null || node === void 0 ? void 0 : node.isMinimized) &&
|
if (target) {
|
||||||
((_b = node === null || node === void 0 ? void 0 : node.body) === null || _b === void 0 ? void 0 : _b.includes(h));
|
return target;
|
||||||
});
|
|
||||||
if (target) {
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
after = (_f = (_e = (_d = repository.pullRequest) === null || _d === void 0 ? void 0 : _d.comments) === null || _e === void 0 ? void 0 : _e.pageInfo) === null || _f === void 0 ? void 0 : _f.endCursor;
|
|
||||||
hasNextPage = (_k = (_j = (_h = (_g = repository.pullRequest) === null || _g === void 0 ? void 0 : _g.comments) === null || _h === void 0 ? void 0 : _h.pageInfo) === null || _j === void 0 ? void 0 : _j.hasNextPage) !== null && _k !== void 0 ? _k : false;
|
|
||||||
}
|
}
|
||||||
return undefined;
|
after = repository.pullRequest?.comments?.pageInfo?.endCursor;
|
||||||
});
|
hasNextPage = repository.pullRequest?.comments?.pageInfo?.hasNextPage ?? false;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
function updateComment(octokit, id, body, header, previousBody) {
|
async function updateComment(octokit, id, body, header, previousBody) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
if (!body && !previousBody)
|
||||||
if (!body && !previousBody)
|
return core.warning("Comment body cannot be blank");
|
||||||
return core.warning("Comment body cannot be blank");
|
const rawPreviousBody = previousBody ? bodyWithoutHeader(previousBody, header) : "";
|
||||||
const rawPreviousBody = previousBody ? bodyWithoutHeader(previousBody, header) : "";
|
await octokit.graphql(`
|
||||||
yield octokit.graphql(`
|
|
||||||
mutation($input: UpdateIssueCommentInput!) {
|
mutation($input: UpdateIssueCommentInput!) {
|
||||||
updateIssueComment(input: $input) {
|
updateIssueComment(input: $input) {
|
||||||
issueComment {
|
issueComment {
|
||||||
|
|
@ -130,45 +114,42 @@ function updateComment(octokit, id, body, header, previousBody) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, {
|
`, {
|
||||||
input: {
|
input: {
|
||||||
id,
|
id,
|
||||||
body: previousBody
|
body: previousBody
|
||||||
? bodyWithHeader(`${rawPreviousBody}\n${body}`, header)
|
? bodyWithHeader(`${rawPreviousBody}\n${body}`, header)
|
||||||
: bodyWithHeader(body, header)
|
: bodyWithHeader(body, header)
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function createComment(octokit, repo, issue_number, body, header, previousBody) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
if (!body && !previousBody) {
|
|
||||||
core.warning("Comment body cannot be blank");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
return yield octokit.rest.issues.createComment(Object.assign(Object.assign({}, repo), { issue_number, body: previousBody ? `${previousBody}\n${body}` : bodyWithHeader(body, header) }));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function deleteComment(octokit, id) {
|
async function createComment(octokit, repo, issue_number, body, header, previousBody) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
if (!body && !previousBody) {
|
||||||
yield octokit.graphql(`
|
core.warning("Comment body cannot be blank");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return await octokit.rest.issues.createComment({
|
||||||
|
...repo,
|
||||||
|
issue_number,
|
||||||
|
body: previousBody ? `${previousBody}\n${body}` : bodyWithHeader(body, header)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
async function deleteComment(octokit, id) {
|
||||||
|
await octokit.graphql(`
|
||||||
mutation($id: ID!) {
|
mutation($id: ID!) {
|
||||||
deleteIssueComment(input: { id: $id }) {
|
deleteIssueComment(input: { id: $id }) {
|
||||||
clientMutationId
|
clientMutationId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, { id });
|
`, { id });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
function minimizeComment(octokit, subjectId, classifier) {
|
async function minimizeComment(octokit, subjectId, classifier) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
await octokit.graphql(`
|
||||||
yield octokit.graphql(`
|
|
||||||
mutation($input: MinimizeCommentInput!) {
|
mutation($input: MinimizeCommentInput!) {
|
||||||
minimizeComment(input: $input) {
|
minimizeComment(input: $input) {
|
||||||
clientMutationId
|
clientMutationId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, { input: { subjectId, classifier } });
|
`, { input: { subjectId, classifier } });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
function getBodyOf(previous, append, hideDetails) {
|
function getBodyOf(previous, append, hideDetails) {
|
||||||
if (!append) {
|
if (!append) {
|
||||||
|
|
@ -225,16 +206,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
||||||
return result;
|
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) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
var _a, _b;
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.ignoreEmpty = exports.githubToken = exports.hideOldComment = exports.skipUnchanged = exports.onlyUpdateComment = exports.onlyCreateComment = exports.deleteOldComment = exports.hideClassify = exports.hideAndRecreate = exports.recreate = exports.hideDetails = exports.append = exports.header = exports.repo = exports.pullRequestNumber = void 0;
|
exports.ignoreEmpty = exports.githubToken = exports.hideOldComment = exports.skipUnchanged = exports.onlyUpdateComment = exports.onlyCreateComment = exports.deleteOldComment = exports.hideClassify = exports.hideAndRecreate = exports.recreate = exports.hideDetails = exports.append = exports.header = exports.repo = exports.pullRequestNumber = void 0;
|
||||||
exports.getBody = getBody;
|
exports.getBody = getBody;
|
||||||
|
|
@ -242,7 +213,7 @@ const node_fs_1 = __nccwpck_require__(3024);
|
||||||
const core = __importStar(__nccwpck_require__(7484));
|
const core = __importStar(__nccwpck_require__(7484));
|
||||||
const github_1 = __nccwpck_require__(3228);
|
const github_1 = __nccwpck_require__(3228);
|
||||||
const glob_1 = __nccwpck_require__(7206);
|
const glob_1 = __nccwpck_require__(7206);
|
||||||
exports.pullRequestNumber = ((_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 });
|
exports.pullRequestNumber = github_1.context?.payload?.pull_request?.number || +core.getInput("number", { required: false });
|
||||||
exports.repo = buildRepo();
|
exports.repo = buildRepo();
|
||||||
exports.header = core.getInput("header", { required: false });
|
exports.header = core.getInput("header", { required: false });
|
||||||
exports.append = core.getBooleanInput("append", { required: true });
|
exports.append = core.getBooleanInput("append", { required: true });
|
||||||
|
|
@ -277,31 +248,29 @@ function buildRepo() {
|
||||||
repo: core.getInput("repo", { required: false }) || github_1.context.repo.repo
|
repo: core.getInput("repo", { required: false }) || github_1.context.repo.repo
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function getBody() {
|
async function getBody() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
const pathInput = core.getMultilineInput("path", { required: false });
|
||||||
const pathInput = core.getMultilineInput("path", { required: false });
|
const followSymbolicLinks = core.getBooleanInput("follow_symbolic_links", {
|
||||||
const followSymbolicLinks = core.getBooleanInput("follow_symbolic_links", {
|
required: true
|
||||||
required: true
|
|
||||||
});
|
|
||||||
if (pathInput && pathInput.length > 0) {
|
|
||||||
try {
|
|
||||||
const globber = yield (0, glob_1.create)(pathInput.join("\n"), {
|
|
||||||
followSymbolicLinks,
|
|
||||||
matchDirectories: false
|
|
||||||
});
|
|
||||||
return (yield globber.glob()).map(path => (0, node_fs_1.readFileSync)(path, "utf-8")).join("\n");
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
if (error instanceof Error) {
|
|
||||||
core.setFailed(error.message);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return core.getInput("message", { required: false });
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
if (pathInput && pathInput.length > 0) {
|
||||||
|
try {
|
||||||
|
const globber = await (0, glob_1.create)(pathInput.join("\n"), {
|
||||||
|
followSymbolicLinks,
|
||||||
|
matchDirectories: false
|
||||||
|
});
|
||||||
|
return (await globber.glob()).map(path => (0, node_fs_1.readFileSync)(path, "utf-8")).join("\n");
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
core.setFailed(error.message);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return core.getInput("message", { required: false });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -345,95 +314,84 @@ var __importStar = (this && this.__importStar) || (function () {
|
||||||
return result;
|
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) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const core = __importStar(__nccwpck_require__(7484));
|
const core = __importStar(__nccwpck_require__(7484));
|
||||||
const github = __importStar(__nccwpck_require__(3228));
|
const github = __importStar(__nccwpck_require__(3228));
|
||||||
const comment_1 = __nccwpck_require__(9661);
|
const comment_1 = __nccwpck_require__(9661);
|
||||||
const config_1 = __nccwpck_require__(6472);
|
const config_1 = __nccwpck_require__(6472);
|
||||||
function run() {
|
async function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
if (Number.isNaN(config_1.pullRequestNumber) || config_1.pullRequestNumber < 1) {
|
||||||
if (Number.isNaN(config_1.pullRequestNumber) || config_1.pullRequestNumber < 1) {
|
core.info("no pull request numbers given: skip step");
|
||||||
core.info("no pull request numbers given: skip step");
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const body = await (0, config_1.getBody)();
|
||||||
|
if (!body && config_1.ignoreEmpty) {
|
||||||
|
core.info("no body given: skip step by ignoreEmpty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
if (!config_1.deleteOldComment && !config_1.hideOldComment && !body) {
|
||||||
const body = yield (0, config_1.getBody)();
|
throw new Error("Either message or path input is required");
|
||||||
if (!body && config_1.ignoreEmpty) {
|
|
||||||
core.info("no body given: skip step by ignoreEmpty");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!config_1.deleteOldComment && !config_1.hideOldComment && !body) {
|
|
||||||
throw new Error("Either message or path input is required");
|
|
||||||
}
|
|
||||||
if (config_1.deleteOldComment && config_1.recreate) {
|
|
||||||
throw new Error("delete and recreate cannot be both set to true");
|
|
||||||
}
|
|
||||||
if (config_1.onlyCreateComment && config_1.onlyUpdateComment) {
|
|
||||||
throw new Error("only_create and only_update cannot be both set to true");
|
|
||||||
}
|
|
||||||
if (config_1.hideOldComment && config_1.hideAndRecreate) {
|
|
||||||
throw new Error("hide and hide_and_recreate cannot be both set to true");
|
|
||||||
}
|
|
||||||
const octokit = github.getOctokit(config_1.githubToken);
|
|
||||||
const previous = yield (0, comment_1.findPreviousComment)(octokit, config_1.repo, config_1.pullRequestNumber, config_1.header);
|
|
||||||
core.setOutput("previous_comment_id", previous === null || previous === void 0 ? void 0 : previous.id);
|
|
||||||
if (config_1.deleteOldComment) {
|
|
||||||
if (previous) {
|
|
||||||
yield (0, comment_1.deleteComment)(octokit, previous.id);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!previous) {
|
|
||||||
if (config_1.onlyUpdateComment) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const created = yield (0, comment_1.createComment)(octokit, config_1.repo, config_1.pullRequestNumber, body, config_1.header);
|
|
||||||
core.setOutput("created_comment_id", created === null || created === void 0 ? void 0 : created.data.id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (config_1.onlyCreateComment) {
|
|
||||||
// don't comment anything, user specified only_create and there is an
|
|
||||||
// existing comment, so this is probably a placeholder / introduction one.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (config_1.hideOldComment) {
|
|
||||||
yield (0, comment_1.minimizeComment)(octokit, previous.id, config_1.hideClassify);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (config_1.skipUnchanged && (0, comment_1.commentsEqual)(body, previous.body || "", config_1.header)) {
|
|
||||||
// don't recreate or update if the message is unchanged
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const previousBody = (0, comment_1.getBodyOf)({ body: previous.body || "" }, config_1.append, config_1.hideDetails);
|
|
||||||
if (config_1.recreate) {
|
|
||||||
yield (0, comment_1.deleteComment)(octokit, previous.id);
|
|
||||||
const created = yield (0, comment_1.createComment)(octokit, config_1.repo, config_1.pullRequestNumber, body, config_1.header, previousBody);
|
|
||||||
core.setOutput("created_comment_id", created === null || created === void 0 ? void 0 : created.data.id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (config_1.hideAndRecreate) {
|
|
||||||
yield (0, comment_1.minimizeComment)(octokit, previous.id, config_1.hideClassify);
|
|
||||||
const created = yield (0, comment_1.createComment)(octokit, config_1.repo, config_1.pullRequestNumber, body, config_1.header);
|
|
||||||
core.setOutput("created_comment_id", created === null || created === void 0 ? void 0 : created.data.id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
yield (0, comment_1.updateComment)(octokit, previous.id, body, config_1.header, previousBody);
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
if (config_1.deleteOldComment && config_1.recreate) {
|
||||||
if (error instanceof Error) {
|
throw new Error("delete and recreate cannot be both set to true");
|
||||||
core.setFailed(error.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
if (config_1.onlyCreateComment && config_1.onlyUpdateComment) {
|
||||||
|
throw new Error("only_create and only_update cannot be both set to true");
|
||||||
|
}
|
||||||
|
if (config_1.hideOldComment && config_1.hideAndRecreate) {
|
||||||
|
throw new Error("hide and hide_and_recreate cannot be both set to true");
|
||||||
|
}
|
||||||
|
const octokit = github.getOctokit(config_1.githubToken);
|
||||||
|
const previous = await (0, comment_1.findPreviousComment)(octokit, config_1.repo, config_1.pullRequestNumber, config_1.header);
|
||||||
|
core.setOutput("previous_comment_id", previous?.id);
|
||||||
|
if (config_1.deleteOldComment) {
|
||||||
|
if (previous) {
|
||||||
|
await (0, comment_1.deleteComment)(octokit, previous.id);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!previous) {
|
||||||
|
if (config_1.onlyUpdateComment) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const created = await (0, comment_1.createComment)(octokit, config_1.repo, config_1.pullRequestNumber, body, config_1.header);
|
||||||
|
core.setOutput("created_comment_id", created?.data.id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (config_1.onlyCreateComment) {
|
||||||
|
// don't comment anything, user specified only_create and there is an
|
||||||
|
// existing comment, so this is probably a placeholder / introduction one.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (config_1.hideOldComment) {
|
||||||
|
await (0, comment_1.minimizeComment)(octokit, previous.id, config_1.hideClassify);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (config_1.skipUnchanged && (0, comment_1.commentsEqual)(body, previous.body || "", config_1.header)) {
|
||||||
|
// don't recreate or update if the message is unchanged
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const previousBody = (0, comment_1.getBodyOf)({ body: previous.body || "" }, config_1.append, config_1.hideDetails);
|
||||||
|
if (config_1.recreate) {
|
||||||
|
await (0, comment_1.deleteComment)(octokit, previous.id);
|
||||||
|
const created = await (0, comment_1.createComment)(octokit, config_1.repo, config_1.pullRequestNumber, body, config_1.header, previousBody);
|
||||||
|
core.setOutput("created_comment_id", created?.data.id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (config_1.hideAndRecreate) {
|
||||||
|
await (0, comment_1.minimizeComment)(octokit, previous.id, config_1.hideClassify);
|
||||||
|
const created = await (0, comment_1.createComment)(octokit, config_1.repo, config_1.pullRequestNumber, body, config_1.header);
|
||||||
|
core.setOutput("created_comment_id", created?.data.id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await (0, comment_1.updateComment)(octokit, previous.id, body, config_1.header, previousBody);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
core.setFailed(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
|
|
||||||
|
|
|
||||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
|
|
@ -5,7 +5,7 @@ import type {
|
||||||
ReportedContentClassifiers,
|
ReportedContentClassifiers,
|
||||||
Repository,
|
Repository,
|
||||||
User
|
User
|
||||||
} from "@octokit/graphql-schema/schema.d"
|
} from "@octokit/graphql-schema"
|
||||||
|
|
||||||
type CreateCommentResponse = Awaited<
|
type CreateCommentResponse = Awaited<
|
||||||
ReturnType<InstanceType<typeof GitHub>["rest"]["issues"]["createComment"]>
|
ReturnType<InstanceType<typeof GitHub>["rest"]["issues"]["createComment"]>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import {readFileSync} from "node:fs"
|
||||||
import * as core from "@actions/core"
|
import * as core from "@actions/core"
|
||||||
import {context} from "@actions/github"
|
import {context} from "@actions/github"
|
||||||
import {create} from "@actions/glob"
|
import {create} from "@actions/glob"
|
||||||
import type {ReportedContentClassifiers} from "@octokit/graphql-schema/schema.d"
|
import type {ReportedContentClassifiers} from "@octokit/graphql-schema"
|
||||||
|
|
||||||
export const pullRequestNumber =
|
export const pullRequestNumber =
|
||||||
context?.payload?.pull_request?.number || +core.getInput("number", {required: false})
|
context?.payload?.pull_request?.number || +core.getInput("number", {required: false})
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,25 @@
|
||||||
{
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/tsconfig",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
|
"allowSyntheticDefaultImports": true,
|
||||||
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
"declaration": false,
|
||||||
"outDir": "./lib" /* Redirect output structure to the directory. */,
|
"declarationMap": false,
|
||||||
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
"esModuleInterop": true,
|
||||||
"strict": true /* Enable all strict type-checking options. */,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
|
"lib": ["ES2022"],
|
||||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"newLine": "lf",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": false,
|
||||||
|
"pretty": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"strict": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"target": "ES2022",
|
||||||
|
"outDir": "./lib",
|
||||||
|
"rootDir": "./src"
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "**/*.test.ts"]
|
"exclude": ["node_modules", "**/*.test.ts"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue