Skip to content

Commit c923d52

Browse files
committed
Use discussion graphql API to add a comment
1 parent 9afe756 commit c923d52

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

action.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Accessibility alt text bot
2-
description: 'This action will check a repos issue and pr comments for correct alt text usage.'
2+
description: 'This action will check a repos issue, discussion, or PR for correct alt text usage.'
33
branding:
44
icon: 'eye'
55
color: 'purple'
@@ -28,6 +28,12 @@ runs:
2828
comment_owner=${{ github.event.pull_request.user.login }}
2929
is_pr=true
3030
target=" your pull request body"
31+
elif [ ${{ github.event.discussion && !github.event.comment }} ]; then
32+
comment='${{ github.event.discussion.body }}'
33+
discussion_node_id='${{ github.event.discussion.node_id }}'
34+
comment_owner=${{ github.event.discussion.user.login }}
35+
target='your discussion description'
36+
is_discussion=true
3137
fi
3238
message="Uh oh! @$comment_owner, the image you shared is missing helpful alt text. Check $target.
3339
@@ -38,6 +44,16 @@ runs:
3844
if [[ $flag = true ]]; then
3945
if [[ $is_pr = true ]]; then
4046
gh pr comment $issue --body "$message"
47+
elif [[ $is_discussion = true ]]; then
48+
gh api graphql -F discussionId="$discussion_node_id" -F body="$message" -f query='
49+
mutation($discussionId: ID!, $body: String!, $replyToId: ID) {
50+
addDiscussionComment(input: {discussionId: $discussionId, body: $body}) {
51+
comment {
52+
id
53+
}
54+
}
55+
}
56+
'
4157
else
4258
gh issue comment $issue --body "$message"
4359
fi

0 commit comments

Comments
 (0)