mirror of
https://github.com/peter-evans/create-or-update-comment.git
synced 2025-01-19 03:26:42 +08:00
Update comment first, then fallback to issue.
This commit is contained in:
parent
7d1077e7f9
commit
19077d62be
40
index.js
40
index.js
@ -55,26 +55,8 @@ async function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const octokit = new github.GitHub(inputs.token);
|
const octokit = new github.GitHub(inputs.token);
|
||||||
|
|
||||||
if (inputs.issueNumber) {
|
if (inputs.commentId) {
|
||||||
// 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) {
|
|
||||||
// Edit a comment
|
// Edit a comment
|
||||||
if (!inputs.body && !inputs.reactionType) {
|
if (!inputs.body && !inputs.reactionType) {
|
||||||
core.setFailed("Missing either comment 'body' or 'reaction-type'.");
|
core.setFailed("Missing either comment 'body' or 'reaction-type'.");
|
||||||
@ -108,6 +90,24 @@ async function run() {
|
|||||||
if (inputs.reactionType) {
|
if (inputs.reactionType) {
|
||||||
await addReaction(octokit, repo, inputs.commentId, 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 {
|
} else {
|
||||||
core.setFailed("Missing either 'issue-number' or 'comment-id'.");
|
core.setFailed("Missing either 'issue-number' or 'comment-id'.");
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user