Skip to content

Commit 540afd6

Browse files
Update handle_external_pr.py and trigger-ai-reviewer.yml to post AI reviewer introduction comment for review requests.
1 parent 9dde0e2 commit 540afd6

2 files changed

Lines changed: 29 additions & 21 deletions

File tree

.github/github_workflow_scripts/handle_external_pr.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,8 @@ def replace_fixes_to_related_in_pr_body(pr: PullRequest) -> str:
496496
pr.edit(body=edited_body)
497497
return ""
498498

499-
def post_ai_introduction(pr: PullRequest, reviewers: list[str], t: Terminal) -> None:
499+
500+
def post_ai_review_introduction(pr: PullRequest, reviewers: list[str], t: Terminal) -> None:
500501
"""
501502
Posts the AI reviewer introduction comment.
502503
@@ -511,7 +512,6 @@ def post_ai_introduction(pr: PullRequest, reviewers: list[str], t: Terminal) ->
511512
print(f"{t.cyan}Posted AI reviewer introduction comment{t.normal}")
512513

513514

514-
515515
def main():
516516
"""Handles External PRs (PRs from forks)
517517
@@ -650,9 +650,8 @@ def main():
650650
if XSOAR_SUPPORT_LEVEL_LABEL or COMMUNITY_SUPPORT_LEVEL_LABEL in labels_to_add and ver != "1.0.0":
651651
pr.create_issue_comment(contributors_body)
652652

653-
post_ai_introduction(pr, reviewers, t)
653+
post_ai_review_introduction(pr, reviewers, t)
654+
654655

655-
656-
657656
if __name__ == "__main__":
658657
main()

.github/workflows/trigger-ai-reviewer.yml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Trigger AI Reviewer
33
on:
44
issue_comment:
55
types: [created]
6+
pull_request:
7+
types: [review_requested]
68

79
env:
810
IGNORED_BOTS: '["content-bot", "xsoar-bot", "dependabot"]'
@@ -15,37 +17,44 @@ jobs:
1517
contents: write
1618
pull-requests: read
1719
if: >-
18-
github.event.issue.pull_request &&
19-
(github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') &&
20-
!contains(fromJson(env.IGNORED_BOTS), github.event.comment.user.login) && contains(
21-
fromJson(env.ALLOWED_COMMANDS), github.event.comment.body
22-
)
20+
# Review request via PR commented command.
21+
(github.event_name == 'issue_comment' &&
22+
github.event.issue.pull_request &&
23+
(github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') &&
24+
!contains(fromJson(env.IGNORED_BOTS), github.event.comment.user.login) &&
25+
contains(fromJson(env.ALLOWED_COMMANDS), github.event.comment.body)) ||
26+
# Review request via GH UI button
27+
(github.event_name == 'pull_request' &&
28+
github.event.requested_reviewer.login == 'content-bot')
2329
steps:
2430
- name: Checkout
2531
uses: actions/checkout@v4
2632
with:
2733
fetch-depth: 0
28-
29-
- name: AI Reviewer Commands Detection
34+
35+
- name: Add Reaction
36+
if: github.event_name == 'issue_comment'
3037
env:
3138
GITHUB_TOKEN: ${{ secrets.CONTENTBOT_GH_ADMIN_TOKEN }}
32-
COMMENT_BODY: ${{ github.event.comment.body }}
3339
COMMENT_ID: ${{ github.event.comment.id }}
34-
ISSUE_NUMBER: ${{ github.event.issue.number }}
3540
REPO: ${{ github.repository }}
3641
run: |
37-
38-
# Add rocket reaction to mark review as in-progress
3942
echo "Adding 🚀 reaction..."
40-
gh api "repos/$REPO/issues/comments/$COMMENT_ID/reactions" -f content="rocket" || {
41-
echo "⚠️ Failed to add reaction. Proceeding anyway..."
42-
}
43+
gh api "repos/$REPO/issues/comments/$COMMENT_ID/reactions" -f content="rocket" || true
44+
45+
- name: Trigger AI Review
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.CONTENTBOT_GH_ADMIN_TOKEN }}
48+
COMMENT_ID: ${{ github.event.comment.id }}
49+
TRIGGER_TYPE: ${{ github.event_name }}
50+
run: |
51+
echo "🚀 Triggering AI Reviewer (via $TRIGGER_TYPE)..."
4352
44-
# Trigger review by pushing an empty commit
45-
echo "Triggering AI Reviewer..."
4653
git config --global user.email "bot@demisto.com"
4754
git config --global user.name "Content Bot"
55+
4856
git commit --allow-empty -m "Trigger AI Reviewer"
57+
4958
git push
5059
5160

0 commit comments

Comments
 (0)