Skip to content

Commit 7d06d79

Browse files
committed
ci: add lgtm code reviewer
1 parent 18e12b0 commit 7d06d79

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

.github/workflows/lgtm.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: LGTM Review
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
lgtm-review:
9+
if: |
10+
github.event.issue.pull_request &&
11+
startsWith(github.event.comment.body, '/lgtm review')
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check if commenter has write access
15+
id: check-permission
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
run: |
19+
USER=${{ github.event.comment.user.login }}
20+
REPO=${{ github.repository }}
21+
PERMISSION=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
22+
https://api.github.com/repos/$REPO/collaborators/$USER/permission \
23+
| jq -r '.permission')
24+
25+
26+
if [[ "$PERMISSION" == "admin" || "$PERMISSION" == "maintain" || "$PERMISSION" == "write" ]]; then
27+
echo "HAS_PERMISSION=true" >> $GITHUB_ENV
28+
else
29+
echo "HAS_PERMISSION=false" >> $GITHUB_ENV
30+
fi
31+
32+
- name: Fail if unauthorized
33+
if: env.HAS_PERMISSION == 'false'
34+
run: |
35+
echo "User ${{ github.event.comment.user.login }} is not authorized to trigger this workflow."
36+
exit 1
37+
38+
- name: Checkout PR code
39+
uses: actions/checkout@v4
40+
with:
41+
ref: refs/pull/${{ github.event.issue.number }}/merge
42+
43+
- name: Run LGTM Review
44+
run: |
45+
docker run --rm elementsinteractive/lgtm-ai \
46+
review \
47+
--pr-url "https://github.com/${{ github.repository }}/pull/${{ github.event.issue.number }}" \
48+
--git-api-key "${{ secrets.GITHUB_TOKEN }}" \
49+
--ai-api-key "${{ secrets.AI_API_TOKEN }}" \
50+
-vv

lgtm.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
technologies = ["Golang"]
2+
categories = ["Correctness", "Quality", "Testing", "Security"]
3+
exclude = ["go.mod", "go.sum"]
4+
model = "gemini-2.5-flash-preview-*"
5+
silent = false
6+
publish = true
7+
ai_retries = 2

0 commit comments

Comments
 (0)