Skip to content

Commit 556beed

Browse files
committed
Clean up conditional and set clear type
1 parent e993c06 commit 556beed

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

action.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,30 @@ runs:
1414
comment=$COMMENT
1515
issue=${{ github.event.issue.html_url }}
1616
comment_owner=${{ github.event.comment.user.login }}
17-
is_pr=${{ github.event.issue.pull_request.url != '' }}
17+
if ${{ github.event.issue.pull_request.url != '' }}; then
18+
type=pr_comment
19+
else
20+
type=issue_comment
21+
fi
1822
target=${{ github.event.comment.html_url }}
1923
elif [ ${{ github.event.issue && !github.event.comment }} ]; then
2024
comment=$ISSUE_BODY
2125
issue=${{ github.event.issue.html_url }}
2226
comment_owner=${{ github.event.issue.user.login }}
23-
is_pr=false
27+
type=issue_description
2428
target=" your issue body"
2529
elif [ ${{ github.event.pull_request && !github.event.comment }} ]; then
2630
comment=$PR_BODY
2731
issue=${{ github.event.pull_request.html_url }}
2832
comment_owner=${{ github.event.pull_request.user.login }}
29-
is_pr=true
33+
type=pr_description
3034
target=" your pull request body"
3135
elif [ ${{ github.event.discussion && !github.event.comment }} ]; then
32-
comment='${{ github.event.discussion.body }}'
36+
comment=$DISCUSSION_BODY
3337
discussion_node_id='${{ github.event.discussion.node_id }}'
3438
comment_owner=${{ github.event.discussion.user.login }}
35-
target='your discussion description'
36-
is_discussion=true
39+
target='your discussion body'
40+
type=discussion_description
3741
fi
3842
message="Uh oh! @$comment_owner, the image you shared is missing helpful alt text. Check $target.
3943
@@ -42,9 +46,9 @@ runs:
4246
Learn more about alt text at [Basic writing and formatting syntax: images on GitHub Docs](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#images)."
4347
flag="$(flagAltText "$comment")"
4448
if [[ $flag = true ]]; then
45-
if [[ $is_pr = true ]]; then
49+
if [[ $type = pr_comment ]] || [[ $type = pr_description ]]; then
4650
gh pr comment $issue --body "$message"
47-
elif [[ $is_discussion = true ]]; then
51+
elif [[ $type = discussion_description ]]; then
4852
gh api graphql -F discussionId="$discussion_node_id" -F body="$message" -f query='
4953
mutation($discussionId: ID!, $body: String!) {
5054
addDiscussionComment(input: {discussionId: $discussionId, body: $body}) {
@@ -64,3 +68,4 @@ runs:
6468
COMMENT: ${{ github.event.comment.body }}
6569
ISSUE_BODY: ${{ github.event.issue.body }}
6670
PR_BODY: ${{ github.event.pull_request.body }}
71+
DISCUSSION_BODY: ${{ github.event.discussion.body }}

0 commit comments

Comments
 (0)