Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update comment first, then fallback to issue. #16

Merged
merged 1 commit into from Mar 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 20 additions & 20 deletions index.js
Expand Up @@ -55,26 +55,8 @@ async function run() {
}

const octokit = new github.GitHub(inputs.token);

if (inputs.issueNumber) {
// Create a comment
if (!inputs.body) {
core.setFailed("Missing comment 'body'.");
return;
}
const { data: comment } = await octokit.issues.createComment({
owner: repo[0],
repo: repo[1],
issue_number: inputs.issueNumber,
body: inputs.body
});
core.info(`Created comment on issue '${inputs.issueNumber}'.`);

// Set a comment reaction
if (inputs.reactionType) {
await addReaction(octokit, repo, comment.id, inputs.reactionType);
}
} else if (inputs.commentId) {

if (inputs.commentId) {
// Edit a comment
if (!inputs.body && !inputs.reactionType) {
core.setFailed("Missing either comment 'body' or 'reaction-type'.");
Expand Down Expand Up @@ -108,6 +90,24 @@ async function run() {
if (inputs.reactionType) {
await addReaction(octokit, repo, inputs.commentId, inputs.reactionType);
}
} else if (inputs.issueNumber) {
// Create a comment
if (!inputs.body) {
core.setFailed("Missing comment 'body'.");
return;
}
const { data: comment } = await octokit.issues.createComment({
owner: repo[0],
repo: repo[1],
issue_number: inputs.issueNumber,
body: inputs.body
});
core.info(`Created comment on issue '${inputs.issueNumber}'.`);

// Set a comment reaction
if (inputs.reactionType) {
await addReaction(octokit, repo, comment.id, inputs.reactionType);
}
} else {
core.setFailed("Missing either 'issue-number' or 'comment-id'.");
return;
Expand Down