Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .github/workflows/lgtm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,15 @@ jobs:
needs: check-permission
if: needs.check-permission.outputs.has-permission == 'true'
runs-on: ubuntu-latest
container:
image: elementsinteractive/lgtm-ai
steps:
- name: Checkout PR code
uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.issue.number }}/merge

- name: Run LGTM Review
run: |
lgtm review \
--pr-url "https://github.com/${{ github.repository }}/pull/${{ github.event.issue.number }}" \
--git-api-key "${{ secrets.GITHUB_TOKEN }}" \
--ai-api-key "${{ secrets.AI_API_TOKEN }}" \
-vv
uses: ./
with:
ai-api-key: ${{ secrets.AI_API_TOKEN }}
git-api-key: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ github.event.issue.number }}
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,18 @@ lgtm-review:
MR_URL: "${CI_PROJECT_URL}/-/merge_requests/${CI_MERGE_REQUEST_IID}"
```

For GitHub, we plan to provide a GitHub action soon. In the meantime, check out this repo's [lgtm workflow](./.github/workflows/lgtm.yml), with which you can trigger reviews in PRs by commenting `/lgtm review`.
For GitHub, you can use the official LGTM AI GitHub Action:

```yaml
- name: AI Code Review
uses: elementsinteractive/lgtm-ai@v1
with:
ai-api-key: ${{ secrets.AI_API_KEY }}
git-api-key: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ github.event.issue.number }}
```

You can also check out this repo's [lgtm workflow](./.github/workflows/lgtm.yml) for a complete example with comment triggers (`/lgtm review`).

### Configuration

Expand Down
82 changes: 82 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: "LGTM AI Code Review"
description: "AI-powered code review for pull requests"
author: "Elements Interactive"

branding:
icon: "moon"
color: "blue"

inputs:
ai-api-key:
description: "API key for AI service (OpenAI, Anthropic, Google, etc.)"
required: true

git-api-key:
description: "API key for GitHub (you can use GITHUB_TOKEN)"
required: true

pr-number:
description: "Pull request number to review"
required: true

model:
description: "AI model to use (e.g. gpt-4o, claude-3-5-sonnet-latest, gemini-2.0-flash)"
required: false
default: "gpt-5"

version:
description: "LGTM AI version (latest, v0.7.2, etc.)"
required: false
default: "latest"

publish:
description: "Whether to publish the review as PR comments"
required: false
default: "true"

exclude:
description: "File patterns to exclude (e.g. '*.md *.json package-lock.json')"
required: false
default: ""

config:
description: "Path to lgtm.toml configuration file (e.g. '.lgtm.toml')"
required: false
default: ""

runs:
using: "composite"
steps:
- name: Run LGTM AI Review
shell: bash
run: |
# Build arguments as an array for safety (avoids word-splitting issues)
ARGS=(
review
--pr-url "https://github.com/${{ github.repository }}/pull/${{ inputs.pr-number }}"
--git-api-key "${{ inputs.git-api-key }}"
--ai-api-key "${{ inputs.ai-api-key }}"
--model "${{ inputs.model }}"
)

# Optional flags
if [ "${{ inputs.publish }}" = "true" ]; then
ARGS+=(--publish)
fi

if [ -n "${{ inputs.exclude }}" ]; then
ARGS+=(--exclude "${{ inputs.exclude }}")
fi

if [ -n "${{ inputs.config }}" ]; then
ARGS+=(--config "${{ inputs.config }}")
fi

# Verbose mode
ARGS+=(-v)

docker run --rm \
-v "${{ github.workspace }}:/workspace" \
-w /workspace \
elementsinteractive/lgtm-ai:${{ inputs.version }} \
"${ARGS[@]}"