Skip to content

Commit

Permalink
feat: Echo comments on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
peterkrauz committed Sep 16, 2022
1 parent 5d414f7 commit 591db92
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

steps:
- name: Search pull-request comments
uses: peterkrauz/search-pull-request-comments@v0.0.7
uses: peterkrauz/search-pull-request-comments@v0.0.8
env:
REQUIRED_COMMENT_USER: "john-doe"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
15 changes: 9 additions & 6 deletions core/search_pull_request_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def fetch(url: str, token: str) -> list:


def search_comments(github_info, token: str, required_user):

if isinstance(github_info, str):
github_info = loads(github_info)

Expand All @@ -26,14 +25,18 @@ def search_comments(github_info, token: str, required_user):
users_that_left_a_comment = [c["user"]["login"] for c in (simple_comments + review_comments)]
required_user_has_commented = str(required_user) in users_that_left_a_comment

if required_user_has_commented:
return 0

return 1
return {
"comments": users_that_left_a_comment,
"required_user_has_commented": required_user_has_commented
}


if __name__ == "__main__":
import sys

result = search_comments(sys.argv[1], sys.argv[2], sys.argv[3])
print(result)

if result["required_user_has_commented"]:
print(0)
else:
print(result["comments"])
3 changes: 2 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ echo "Result: $result"
if [ "$result" = "0" ]; then
echo "User that was required to comment did leave a comment - all good!"
else
echo "Couldn't find any comment from the required user"
echo "Couldn't find any comment from the required user\n"
echo "Here's everyone that did comment: $result"
exit 1
fi

0 comments on commit 591db92

Please sign in to comment.