Skip to content

Commit dd0a548

Browse files
authored
Update presubmit.yml logic to run on review requested or pr comments from mantainers
1 parent e155116 commit dd0a548

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

.github/workflows/presubmit.yml

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,56 @@
1-
name: Presubmit.ai
2-
3-
permissions:
4-
contents: read
5-
pull-requests: write
6-
issues: write
1+
name: Presubmit.ai PR Review
72

83
on:
9-
pull_request_review:
4+
pull_request_target:
5+
types: [review_requested]
6+
issue_comment:
7+
types: [created]
108

119
jobs:
12-
review:
10+
check-membership:
1311
runs-on: ubuntu-latest
12+
outputs:
13+
member: ${{ steps.check.outputs.member }}
14+
# Only run this membership check if the comment is on a pull request.
15+
if: github.event_name == 'issue_comment' && github.event.issue.pull_request != null
16+
steps:
17+
- name: Check if commenter is in projectmesa
18+
id: check
19+
run: |
20+
username="${{ github.event.comment.user.login }}"
21+
echo "Checking membership for $username..."
22+
# GitHub API returns a 204 status code if the user is a member.
23+
response=$(curl -s -o /dev/null -w "%{http_code}" \
24+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
25+
https://api.github.com/orgs/projectmesa/members/$username)
26+
if [ "$response" -eq 204 ]; then
27+
echo "::set-output name=member::true"
28+
else
29+
echo "::set-output name=member::false"
30+
fi
31+
32+
run-ai-review:
33+
runs-on: ubuntu-latest
34+
needs: check-membership
35+
if: >
36+
(github.event_name == 'pull_request_target' && github.event.action == 'review_requested')
37+
||
38+
(
39+
github.event_name == 'issue_comment' &&
40+
github.event.issue.pull_request != null &&
41+
contains(github.event.comment.body, '/pr-ai-review') &&
42+
needs.check-membership.outputs.member == 'true'
43+
)
1444
steps:
1545
- name: Check required secrets
1646
run: |
1747
if [ -z "${{ secrets.LLM_API_KEY }}" ]; then
1848
echo "Error: LLM_API_KEY secret is not configured"
1949
exit 1
2050
fi
21-
- uses: presubmit/ai-reviewer@latest
51+
52+
- name: Run AI Reviewer
53+
uses: presubmit/ai-reviewer@latest
2254
env:
2355
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2456
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}

0 commit comments

Comments
 (0)