mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2026-04-18 12:05:44 +00:00
fix: add rootDir and types to tsconfig.json to resolve TS5011 build error
Agent-Logs-Url: https://github.com/marocchino/sticky-pull-request-comment/sessions/c726777d-ddec-4ced-8af3-0bafb048ce2f Co-authored-by: marocchino <128431+marocchino@users.noreply.github.com>
This commit is contained in:
parent
6ef1707d4b
commit
c4fbe28317
9 changed files with 546 additions and 0 deletions
68
dist/main.js
generated
vendored
Normal file
68
dist/main.js
generated
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import * as core from "@actions/core";
|
||||
import * as github from "@actions/github";
|
||||
import { commentsEqual, createComment, deleteComment, findPreviousComment, getBodyOf, minimizeComment, updateComment, } from "./comment";
|
||||
import { append, deleteOldComment, getBody, githubToken, header, hideAndRecreate, hideClassify, hideDetails, hideOldComment, ignoreEmpty, onlyCreateComment, onlyUpdateComment, pullRequestNumber, recreate, repo, skipUnchanged, } from "./config";
|
||||
import { validateBody, validateExclusiveModes } from "./validate";
|
||||
async function run() {
|
||||
if (Number.isNaN(pullRequestNumber) || pullRequestNumber < 1) {
|
||||
core.info("no pull request numbers given: skip step");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
validateExclusiveModes(deleteOldComment, recreate, onlyCreateComment, onlyUpdateComment, hideOldComment, hideAndRecreate);
|
||||
const body = await getBody();
|
||||
if (!body && ignoreEmpty) {
|
||||
core.info("no body given: skip step by ignoreEmpty");
|
||||
return;
|
||||
}
|
||||
validateBody(body, deleteOldComment, hideOldComment);
|
||||
const octokit = github.getOctokit(githubToken);
|
||||
const previous = await findPreviousComment(octokit, repo, pullRequestNumber, header);
|
||||
core.setOutput("previous_comment_id", previous?.id);
|
||||
if (!previous) {
|
||||
if (onlyUpdateComment || hideOldComment || deleteOldComment) {
|
||||
return;
|
||||
}
|
||||
const created = await createComment(octokit, repo, pullRequestNumber, body, header);
|
||||
core.setOutput("created_comment_id", created?.data.id);
|
||||
return;
|
||||
}
|
||||
if (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 (hideOldComment) {
|
||||
await minimizeComment(octokit, previous.id, hideClassify);
|
||||
return;
|
||||
}
|
||||
if (deleteOldComment) {
|
||||
await deleteComment(octokit, previous.id);
|
||||
return;
|
||||
}
|
||||
if (skipUnchanged && commentsEqual(body, previous.body || "", header)) {
|
||||
// don't recreate or update if the message is unchanged
|
||||
return;
|
||||
}
|
||||
const previousBody = getBodyOf({ body: previous.body || "" }, append, hideDetails);
|
||||
if (recreate) {
|
||||
await deleteComment(octokit, previous.id);
|
||||
const created = await createComment(octokit, repo, pullRequestNumber, body, header, previousBody);
|
||||
core.setOutput("created_comment_id", created?.data.id);
|
||||
return;
|
||||
}
|
||||
if (hideAndRecreate) {
|
||||
await minimizeComment(octokit, previous.id, hideClassify);
|
||||
const created = await createComment(octokit, repo, pullRequestNumber, body, header);
|
||||
core.setOutput("created_comment_id", created?.data.id);
|
||||
return;
|
||||
}
|
||||
await updateComment(octokit, previous.id, body, header, previousBody);
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof Error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
run();
|
||||
Loading…
Add table
Add a link
Reference in a new issue