Skip to content

Commit 0575c52

Browse files
committed
Bare-bones pr-review gha
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
1 parent 7c85436 commit 0575c52

1 file changed

Lines changed: 4 additions & 103 deletions

File tree

.github/workflows/pr-review.yml

Lines changed: 4 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ name: PR Review on Command
33
on:
44
issue_comment:
55
types: [created]
6-
workflow_dispatch:
7-
inputs:
8-
pr_number:
9-
description: "PR number to review"
10-
required: true
11-
type: number
126

137
permissions:
148
contents: read
@@ -17,110 +11,17 @@ permissions:
1711

1812
jobs:
1913
run-review:
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'
14+
if: github.event.issue.pull_request && contains(github.event.comment.body, '/review')
2315
runs-on: ubuntu-latest
2416
steps:
25-
- name: Get PR number and comment ID
26-
id: get-context
27-
run: |
28-
if [ "${{ github.event_name }}" == "issue_comment" ]; then
29-
echo "pr_number=${{ github.event.issue.number }}" >> $GITHUB_OUTPUT
30-
echo "comment_id=${{ github.event.comment.id }}" >> $GITHUB_OUTPUT
31-
else
32-
echo "pr_number=${{ inputs.pr_number }}" >> $GITHUB_OUTPUT
33-
echo "comment_id=" >> $GITHUB_OUTPUT
34-
fi
35-
36-
- name: Add eyes reaction
37-
if: github.event_name == 'issue_comment'
38-
env:
39-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
COMMENT_ID: ${{ steps.get-context.outputs.comment_id }}
41-
REPO: ${{ github.repository }}
42-
run: |
43-
gh api \
44-
--method POST \
45-
-H "Accept: application/vnd.github+json" \
46-
-H "X-GitHub-Api-Version: 2022-11-28" \
47-
/repos/$REPO/issues/comments/$COMMENT_ID/reactions \
48-
-f content='eyes'
49-
50-
- name: Get PR details
51-
id: pr-details
52-
env:
53-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54-
PR_NUMBER: ${{ steps.get-context.outputs.pr_number }}
55-
REPO: ${{ github.repository }}
56-
run: |
57-
# Get PR details as JSON
58-
pr_json=$(gh pr view $PR_NUMBER --repo $REPO --json title,author,files,headRefName,headRefOid)
59-
60-
# Extract values using jq (pre-installed on ubuntu-latest)
61-
pr_title=$(echo "$pr_json" | jq -r '.title')
62-
pr_author=$(echo "$pr_json" | jq -r '.author.login')
63-
files_changed=$(echo "$pr_json" | jq -r '.files | length')
64-
head_ref=$(echo "$pr_json" | jq -r '.headRefName')
65-
head_sha=$(echo "$pr_json" | jq -r '.headRefOid')
66-
67-
# Set outputs
68-
echo "pr_title=$pr_title" >> $GITHUB_OUTPUT
69-
echo "pr_author=$pr_author" >> $GITHUB_OUTPUT
70-
echo "files_changed=$files_changed" >> $GITHUB_OUTPUT
71-
echo "head_ref=$head_ref" >> $GITHUB_OUTPUT
72-
echo "head_sha=$head_sha" >> $GITHUB_OUTPUT
73-
74-
# Log for debugging
75-
echo "PR #$PR_NUMBER: $pr_title"
76-
echo "Author: $pr_author"
77-
echo "Files changed: $files_changed"
78-
echo "Head ref: $head_ref"
79-
echo "Head SHA: $head_sha"
80-
81-
- name: Checkout PR branch
17+
- name: Checkout repository
8218
uses: actions/checkout@v4
83-
with:
84-
ref: ${{ steps.pr-details.outputs.head_sha }}
85-
fetch-depth: 0 # Full history for proper diff analysis
8619

8720
- name: Run PR Reviewer Agent
8821
uses: docker/cagent-action@1f7ec0445e138a587639fc9c046076e22d184349
8922
with:
9023
agent: ${{ github.workspace }}/.github/workflows/agents/pr-review.yaml
91-
prompt: "Please review this GitHub Pull Request: https://github.com/${{ github.repository }}/pull/${{ steps.get-context.outputs.pr_number }}"
24+
prompt: "Please review this GitHub Pull Request: https://github.com/${{ github.repository }}/pull/${{ github.event.issue.number }}"
9225
mcp-gateway: true
9326
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
94-
github-token: ${{ secrets.GITHUB_TOKEN }}
95-
env:
96-
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
97-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98-
continue-on-error: true
99-
100-
- name: Add success reaction
101-
if: success() && github.event_name == 'issue_comment'
102-
env:
103-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104-
COMMENT_ID: ${{ steps.get-context.outputs.comment_id }}
105-
REPO: ${{ github.repository }}
106-
run: |
107-
gh api \
108-
--method POST \
109-
-H "Accept: application/vnd.github+json" \
110-
-H "X-GitHub-Api-Version: 2022-11-28" \
111-
/repos/$REPO/issues/comments/$COMMENT_ID/reactions \
112-
-f content='rocket'
113-
114-
- name: Add failure reaction
115-
if: failure() && github.event_name == 'issue_comment'
116-
env:
117-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118-
COMMENT_ID: ${{ steps.get-context.outputs.comment_id }}
119-
REPO: ${{ github.repository }}
120-
run: |
121-
gh api \
122-
--method POST \
123-
-H "Accept: application/vnd.github+json" \
124-
-H "X-GitHub-Api-Version: 2022-11-28" \
125-
/repos/$REPO/issues/comments/$COMMENT_ID/reactions \
126-
-f content='confused'
27+
github-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)