Skip to content

Commit

Permalink
Merge pull request #16 from robdodson/reorder
Browse files Browse the repository at this point in the history
Update comment first, then fallback to issue.
  • Loading branch information
peter-evans committed Mar 27, 2020
2 parents 78de0fc + 19077d6 commit c8a511a
Showing 1 changed file with 20 additions and 20 deletions.
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

0 comments on commit c8a511a

Please sign in to comment.