marocchino 2021-08-31 03:39:58 +09:00
parent 72463c317a
commit f202c00725
No known key found for this signature in database
GPG key ID: AFF521DBDB122570
6 changed files with 33 additions and 21 deletions

22
dist/index.js generated vendored
View file

@ -128,10 +128,12 @@ function buildBody() {
const path = core.getInput("path", { required: false }); const path = core.getInput("path", { required: false });
if (path) { if (path) {
try { try {
return fs_1.readFileSync(path, "utf-8"); return (0, fs_1.readFileSync)(path, "utf-8");
} }
catch (error) { catch (error) {
core.setFailed(error.message); if (error instanceof Error) {
core.setFailed(error.message);
}
return ""; return "";
} }
} }
@ -195,25 +197,27 @@ function run() {
throw new Error("delete and recreate cannot be both set to true"); throw new Error("delete and recreate cannot be both set to true");
} }
const octokit = github.getOctokit(config_1.githubToken); const octokit = github.getOctokit(config_1.githubToken);
const previous = yield comment_1.findPreviousComment(octokit, config_1.repo, config_1.pullRequestNumber, config_1.header); const previous = yield (0, comment_1.findPreviousComment)(octokit, config_1.repo, config_1.pullRequestNumber, config_1.header);
if (!previous) { if (!previous) {
yield comment_1.createComment(octokit, config_1.repo, config_1.pullRequestNumber, config_1.body, config_1.header); yield (0, comment_1.createComment)(octokit, config_1.repo, config_1.pullRequestNumber, config_1.body, config_1.header);
return; return;
} }
if (config_1.deleteOldComment) { if (config_1.deleteOldComment) {
yield comment_1.deleteComment(octokit, config_1.repo, previous.id); yield (0, comment_1.deleteComment)(octokit, config_1.repo, previous.id);
return; return;
} }
const previousBody = config_1.append ? previous.body : undefined; const previousBody = config_1.append ? previous.body : undefined;
if (config_1.recreate) { if (config_1.recreate) {
yield comment_1.deleteComment(octokit, config_1.repo, previous.id); yield (0, comment_1.deleteComment)(octokit, config_1.repo, previous.id);
yield comment_1.createComment(octokit, config_1.repo, config_1.pullRequestNumber, config_1.body, config_1.header, previousBody); yield (0, comment_1.createComment)(octokit, config_1.repo, config_1.pullRequestNumber, config_1.body, config_1.header, previousBody);
return; return;
} }
yield comment_1.updateComment(octokit, config_1.repo, previous.id, config_1.body, config_1.header, previousBody); yield (0, comment_1.updateComment)(octokit, config_1.repo, previous.id, config_1.body, config_1.header, previousBody);
} }
catch (error) { catch (error) {
core.setFailed(error.message); if (error instanceof Error) {
core.setFailed(error.message);
}
} }
}); });
} }

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

6
lib/config.js generated
View file

@ -43,10 +43,12 @@ function buildBody() {
const path = core.getInput("path", { required: false }); const path = core.getInput("path", { required: false });
if (path) { if (path) {
try { try {
return fs_1.readFileSync(path, "utf-8"); return (0, fs_1.readFileSync)(path, "utf-8");
} }
catch (error) { catch (error) {
core.setFailed(error.message); if (error instanceof Error) {
core.setFailed(error.message);
}
return ""; return "";
} }
} }

16
lib/main.js generated
View file

@ -46,25 +46,27 @@ function run() {
throw new Error("delete and recreate cannot be both set to true"); throw new Error("delete and recreate cannot be both set to true");
} }
const octokit = github.getOctokit(config_1.githubToken); const octokit = github.getOctokit(config_1.githubToken);
const previous = yield comment_1.findPreviousComment(octokit, config_1.repo, config_1.pullRequestNumber, config_1.header); const previous = yield (0, comment_1.findPreviousComment)(octokit, config_1.repo, config_1.pullRequestNumber, config_1.header);
if (!previous) { if (!previous) {
yield comment_1.createComment(octokit, config_1.repo, config_1.pullRequestNumber, config_1.body, config_1.header); yield (0, comment_1.createComment)(octokit, config_1.repo, config_1.pullRequestNumber, config_1.body, config_1.header);
return; return;
} }
if (config_1.deleteOldComment) { if (config_1.deleteOldComment) {
yield comment_1.deleteComment(octokit, config_1.repo, previous.id); yield (0, comment_1.deleteComment)(octokit, config_1.repo, previous.id);
return; return;
} }
const previousBody = config_1.append ? previous.body : undefined; const previousBody = config_1.append ? previous.body : undefined;
if (config_1.recreate) { if (config_1.recreate) {
yield comment_1.deleteComment(octokit, config_1.repo, previous.id); yield (0, comment_1.deleteComment)(octokit, config_1.repo, previous.id);
yield comment_1.createComment(octokit, config_1.repo, config_1.pullRequestNumber, config_1.body, config_1.header, previousBody); yield (0, comment_1.createComment)(octokit, config_1.repo, config_1.pullRequestNumber, config_1.body, config_1.header, previousBody);
return; return;
} }
yield comment_1.updateComment(octokit, config_1.repo, previous.id, config_1.body, config_1.header, previousBody); yield (0, comment_1.updateComment)(octokit, config_1.repo, previous.id, config_1.body, config_1.header, previousBody);
} }
catch (error) { catch (error) {
core.setFailed(error.message); if (error instanceof Error) {
core.setFailed(error.message);
}
} }
}); });
} }

View file

@ -28,7 +28,9 @@ function buildBody(): string {
try { try {
return readFileSync(path, "utf-8") return readFileSync(path, "utf-8")
} catch (error) { } catch (error) {
core.setFailed(error.message) if (error instanceof Error) {
core.setFailed(error.message)
}
return "" return ""
} }
} else { } else {

View file

@ -66,7 +66,9 @@ async function run(): Promise<undefined> {
await updateComment(octokit, repo, previous.id, body, header, previousBody) await updateComment(octokit, repo, previous.id, body, header, previousBody)
} catch (error) { } catch (error) {
core.setFailed(error.message) if (error instanceof Error) {
core.setFailed(error.message)
}
} }
} }