Support issue comments in GitHub Actions

This commit is contained in:
Ori Kotek
2023-09-12 16:41:12 +03:00
parent 2f6178306f
commit 21feb92b75
2 changed files with 14 additions and 5 deletions

View File

@ -5,4 +5,4 @@ branding:
color: 'green' color: 'green'
runs: runs:
using: 'docker' using: 'docker'
image: 'Dockerfile.github_action_dockerhub' image: 'Dockerfile.github_action'

View File

@ -61,12 +61,21 @@ async def run_action():
if action in ["created", "edited"]: if action in ["created", "edited"]:
comment_body = event_payload.get("comment", {}).get("body") comment_body = event_payload.get("comment", {}).get("body")
if comment_body: if comment_body:
pr_url = event_payload.get("issue", {}).get("pull_request", {}).get("url") is_pr = False
if pr_url: # check if issue is pull request
if event_payload.get("issue", {}).get("pull_request"):
url = event_payload.get("issue", {}).get("pull_request", {}).get("url")
is_pr = True
else:
url = event_payload.get("issue", {}).get("url")
if url:
body = comment_body.strip().lower() body = comment_body.strip().lower()
comment_id = event_payload.get("comment", {}).get("id") comment_id = event_payload.get("comment", {}).get("id")
provider = get_git_provider()(pr_url=pr_url) provider = get_git_provider()(pr_url=url)
await PRAgent().handle_request(pr_url, body, notify=lambda: provider.add_eyes_reaction(comment_id)) if is_pr:
await PRAgent().handle_request(url, body, notify=lambda: provider.add_eyes_reaction(comment_id))
else:
await PRAgent().handle_request(url, body)
if __name__ == '__main__': if __name__ == '__main__':