@@ -16,33 +16,31 @@ function getDiscussionReplyToId() {
16
16
echo $REPLY_TO_DATA | jq -r ' .data.node.replyTo.id'
17
17
}
18
18
19
- # Given a discussion node ID and a message, adds a top-level discussion comment.
19
+ # Given a discussion node ID, a message, and an optional reply to node ID, adds a discussion comment.
20
20
function addDiscussionComment() {
21
21
local DISCUSSION_NODE_ID=$1
22
22
local MESSAGE=$2
23
- gh api graphql -F discussionId=" $discussion_node_id " -F body=" $message " -f query='
24
- mutation($discussionId: ID!, $body: String!) {
25
- addDiscussionComment(input: {discussionId: $discussionId, body: $body}) {
26
- comment {
27
- id
23
+ local REPLY_TO_ID=$3
24
+
25
+ if [ -n " $REPLY_TO_ID " ]; then
26
+ gh api graphql -F discussionId=" $DISCUSSION_NODE_ID " -F replyToId=" $REPLY_TO_ID " -F body=" $MESSAGE " -f query='
27
+ mutation($discussionId: ID!, , $replyToId: ID, $body: String!) {
28
+ addDiscussionComment(input: {discussionId: $discussionId, replyToId: $replyToId, body: $body}) {
29
+ comment {
30
+ id
31
+ }
28
32
}
29
33
}
30
- }
31
- '
32
- }
33
-
34
- # Given a discussion node ID, discussion comment node ID, and a message, adds a discussion comment as a reply in thread.
35
- function addDiscussionCommentAsReply() {
36
- local DISCUSSION_NODE_ID=$1
37
- local REPLY_TO_ID=$2
38
- local MESSAGE=$3
39
- gh api graphql -F discussionId=" $DISCUSSION_NODE_ID " -F replyToId=" $REPLY_TO_ID " -F body=" $MESSAGE " -f query='
40
- mutation($discussionId: ID!, , $replyToId: ID, $body: String!) {
41
- addDiscussionComment(input: {discussionId: $discussionId, replyToId: $replyToId, body: $body}) {
42
- comment {
34
+ '
35
+ else
36
+ gh api graphql -F discussionId=" $discussion_node_id " -F body=" $message " -f query='
37
+ mutation($discussionId: ID!, $body: String!) {
38
+ addDiscussionComment(input: {discussionId: $discussionId, body: $body}) {
39
+ comment {
43
40
id
41
+ }
44
42
}
45
43
}
46
- }
47
- '
44
+ '
45
+ fi
48
46
}
0 commit comments