Skip to content

Commit

Permalink
format src/main.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
rodmatos committed Jan 28, 2022
1 parent 6865320 commit 79af4a7
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
import * as github from '@actions/github';
import * as core from '@actions/core';
import * as github from "@actions/github";
import * as core from "@actions/core";

async function run(): Promise<void> {
try {
const githubToken = core.getInput('github_token', { required: true });
const body = core.getInput('body', { required: true });
const deduplicate = core.getInput('deduplicate', { required: false });
const githubToken = core.getInput("github_token", { required: true });
const body = core.getInput("body", { required: true });
const deduplicate = core.getInput("deduplicate", { required: false });

const octokit = github.getOctokit(githubToken);

let { owner, repo } = github.context.repo;
if (core.getInput('repo')) {
[owner, repo] = core.getInput('repo').split('/');
if (core.getInput("repo")) {
[owner, repo] = core.getInput("repo").split("/");
}

const number =
core.getInput('number') === ''
? github.context.issue.number
: parseInt(core.getInput('number'));
const number = core.getInput("number") === ""
? github.context.issue.number
: parseInt(core.getInput("number"));

if (deduplicate) {
const comments = await octokit.issues.listComments({
owner,
repo,
issue_number: number
})
const comment_ids = comments.filter(comment => comment.body.includes(deduplicate))
issue_number: number,
});
const comment_ids = comments.filter((comment) =>
comment.body.includes(deduplicate)
);
for (const comment_id of comment_ids) {
await octokit.issues.deleteComment({
owner,
repo,
issue_number: number,
comment_id,
})
});
}
}

await octokit.issues.createComment({
owner,
repo,
issue_number: number,
body
body,
});
} catch (e) {
core.error(e);
Expand Down

0 comments on commit 79af4a7

Please sign in to comment.