Skip to content

Commit d13076e

Browse files
committed
Start of a PR reviewer workflow
1 parent 7c07a98 commit d13076e

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: PR Review on Command
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
workflow_dispatch:
7+
inputs:
8+
pr_number:
9+
description: "PR number to review"
10+
required: true
11+
type: number
12+
13+
permissions:
14+
contents: read
15+
pull-requests: write
16+
issues: write
17+
18+
jobs:
19+
check-trigger:
20+
if: |
21+
(github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '/review')) ||
22+
github.event_name == 'workflow_dispatch'
23+
runs-on: ubuntu-latest
24+
outputs:
25+
pr_number: ${{ steps.get-pr.outputs.pr_number }}
26+
steps:
27+
- name: Get PR number
28+
id: get-pr
29+
run: |
30+
if [ "${{ github.event_name }}" == "issue_comment" ]; then
31+
echo "pr_number=${{ github.event.issue.number }}" >> $GITHUB_OUTPUT
32+
else
33+
echo "pr_number=${{ inputs.pr_number }}" >> $GITHUB_OUTPUT
34+
fi
35+
36+
- name: Add eyes reaction
37+
if: github.event_name == 'issue_comment'
38+
uses: actions/github-script@v7
39+
with:
40+
script: |
41+
await github.rest.reactions.createForIssueComment({
42+
owner: context.repo.owner,
43+
repo: context.repo.repo,
44+
comment_id: context.payload.comment.id,
45+
content: 'eyes'
46+
});
47+
48+
run-review:
49+
needs: [check-trigger]
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: Get PR details
53+
id: pr-details
54+
uses: actions/github-script@v7
55+
with:
56+
script: |
57+
const prNumber = ${{ needs.check-trigger.outputs.pr_number }};
58+
const { data: pr } = await github.rest.pulls.get({
59+
owner: context.repo.owner,
60+
repo: context.repo.repo,
61+
pull_number: prNumber
62+
});
63+
const { data: files } = await github.rest.pulls.listFiles({
64+
owner: context.repo.owner,
65+
repo: context.repo.repo,
66+
pull_number: prNumber
67+
});
68+
core.setOutput('pr_title', pr.title);
69+
core.setOutput('pr_author', pr.user.login);
70+
core.setOutput('files_changed', files.length);
71+
core.setOutput('head_ref', pr.head.ref);
72+
73+
- name: Checkout PR branch
74+
uses: actions/checkout@v4
75+
with:
76+
ref: ${{ steps.pr-details.outputs.head_ref }}
77+
78+
- name: Run PR Reviewer Agent
79+
uses: docker/cagent-action@1f7ec0445e138a587639fc9c046076e22d184349
80+
with:
81+
agent: agentcatalog/github-action-pr-reviewer:2.0.0
82+
mcp-gateway: true
83+
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
84+
github-token: ${{ secrets.GITHUB_TOKEN }}
85+
env:
86+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
continue-on-error: true
89+
90+
- name: Add success reaction
91+
if: success() && github.event_name == 'issue_comment'
92+
uses: actions/github-script@v7
93+
with:
94+
script: |
95+
await github.rest.reactions.createForIssueComment({
96+
owner: context.repo.owner,
97+
repo: context.repo.repo,
98+
comment_id: context.payload.comment.id,
99+
content: 'rocket'
100+
});
101+
102+
- name: Add failure reaction
103+
if: failure() && github.event_name == 'issue_comment'
104+
uses: actions/github-script@v7
105+
with:
106+
script: |
107+
await github.rest.reactions.createForIssueComment({
108+
owner: context.repo.owner,
109+
repo: context.repo.repo,
110+
comment_id: context.payload.comment.id,
111+
content: 'confused'
112+
});

0 commit comments

Comments
 (0)