github / accessibility-alt-text-bot

An action to remind users to add alt text on Issues, Pull Requests, and Discussions
MIT License
74 stars 13 forks source link

Add support for discussion comment #17

Closed khiga8 closed 1 year ago

khiga8 commented 1 year ago

Fixes: https://github.com/github/accessibility-alt-text-bot/issues/11

This PR adds support for discussion comments. Because the action.yml is getting big, I introduced a queries.sh file to move the GraphQL calls into, including the mutation call we introduced in https://github.com/github/accessibility-alt-text-bot/pull/14.

We are using the addDiscussionComment and setting the replyToId to post a comment as a reply in a thread.

When replying to a top-level discussion comment, we're able to use github.event.comment.node_id as the replyToId to post a reply successfully.

However, I ran into issues making the same call when replying to a discussion comment inside of a thread. I kept running into the error:

gh: Parent comment is already in a thread, cannot reply to it

I discovered that replyToId has to be a top-level/parent comment node id. Since the github.event.comment.node_id only contains the node ID of the comment we're replying to, we must make a GraphQL query to get the parent comment node ID. We do that in the function getDiscussionReplyToId.

accessibility-bot commented 1 year ago

:wave: Hello and thanks for pinging us! You've entered our first responder queue. An accessibility first responder will review this soon.