-
Notifications
You must be signed in to change notification settings - Fork 3
126 lines (113 loc) · 3.91 KB
/
copilot-review.yaml
File metadata and controls
126 lines (113 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: AI Code Review
on:
workflow_call:
inputs:
pr_number:
description: 'Pull request number to review'
required: true
type: number
tool:
description: 'AI CLI tool to use: copilot or opencode'
required: false
type: string
default: 'copilot'
model:
description: 'AI model (default depends on tool: claude-sonnet-4 for copilot, github-copilot/claude-sonnet-4 for opencode)'
required: false
type: string
default: ''
additional_instructions:
description: 'Additional review instructions (max 1000 chars)'
required: false
type: string
default: ''
comment_id:
description: 'Issue comment ID for emoji reactions (0 to skip reactions)'
required: false
type: number
default: 0
inline_review:
description: 'Post findings as inline PR review comments on specific lines'
required: false
type: boolean
default: false
secrets:
COPILOT_TOKEN:
description: 'Fine-grained PAT with Copilot Requests permission (required for copilot tool)'
required: false
permissions:
contents: read
pull-requests: write
concurrency:
group: ai-review-${{ github.repository }}-pr-${{ inputs.pr_number }}
cancel-in-progress: true
jobs:
review:
name: AI Code Review
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout automation scripts
uses: actions/checkout@v4
with:
repository: scylladb/github-automation
path: .automation
sparse-checkout: .github/scripts/copilot-review.py
sparse-checkout-cone-mode: false
- name: Validate Copilot token
if: inputs.tool == 'copilot'
run: |
if [ -z "$COPILOT_GITHUB_TOKEN" ]; then
echo "::error::COPILOT_TOKEN secret is required when tool=copilot but was not provided"
exit 1
fi
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_TOKEN }}
- name: Setup Node.js
if: inputs.tool == 'copilot'
uses: actions/setup-node@v4
- name: Install Copilot CLI
if: inputs.tool == 'copilot'
run: npm install -g @github/copilot
- name: Install OpenCode CLI
if: inputs.tool == 'opencode'
run: |
curl -fsSL https://opencode.ai/install | bash
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Run review
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_TOKEN }}
GH_TOKEN: ${{ github.token }}
REVIEW_REPO: ${{ github.repository }}
REVIEW_INSTRUCTIONS: ${{ inputs.additional_instructions }}
REVIEW_TOOL: ${{ inputs.tool }}
REVIEW_MODEL: ${{ inputs.model }}
REVIEW_INLINE: ${{ inputs.inline_review }}
REVIEW_PR_NUMBER: ${{ inputs.pr_number }}
REVIEW_COMMENT_ID: ${{ inputs.comment_id }}
REVIEW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
REVIEW_RUN_ID: ${{ github.run_id }}
run: |
args=(
--repo "$REVIEW_REPO"
--pr-number "$REVIEW_PR_NUMBER"
--tool "$REVIEW_TOOL"
--additional-instructions "$REVIEW_INSTRUCTIONS"
--comment-id "$REVIEW_COMMENT_ID"
--run-url "$REVIEW_RUN_URL"
--run-id "$REVIEW_RUN_ID"
)
if [ -n "$REVIEW_MODEL" ]; then
args+=(--model "$REVIEW_MODEL")
fi
if [ "$REVIEW_INLINE" = "true" ]; then
args+=(--inline-review)
fi
python3 .automation/.github/scripts/copilot-review.py "${args[@]}"
- name: Upload review artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: ai-review-PR${{ inputs.pr_number }}
path: /tmp/copilot-review/
retention-days: 30