I'm working on a GitHub Action triggered on the comment of a certain discussion (say org/repo/discussions/6#discussioncomment-7349183
) being created or edited. I'd like the action to reply the comment like "your pipeline is running here" with a link.
Then I found that there's only GraphQL way to add a reply like:
mutation {
addDiscussionComment(input:{
discussionId: "D_something",
replyToId: "DC_something_",
body: "Test reply",
}) {
clientMutationId
comment {
id
body
}
}
}
I'd like to get the Node ID of the comment with github.event.comment.id
in the pipeline and use it as replyToId
, but comments
only accepts these arguments:
after: String
Returns the elements in the list that come after the specified cursor.
before: String
Returns the elements in the list that come before the specified cursor.
first: Int
Returns the first n elements from the list.
last: Int
Returns the last n elements from the list.
Which means I'll use a query like:
{
repository(owner: "org", name: "repo") {
discussion(number: 6) {
comments(first: 1) {
nodes {
id
}
}
}
}
}
However I don't know the position of github.event.comment.id
as the triggerer is not guaranteed to be the last comment.
Could you please show me how to get the comment's Node ID?
My temporary walkaround is to get the id
and url
of the first 100 comments, and search for the url
ending with github.event.comment.id
, the corresponding id
is the Node ID I need. Is there any cleaner & better solution?