|
| 1 | +name: "LGTM AI Code Review" |
| 2 | +description: "AI-powered code review for pull requests" |
| 3 | +author: "Elements Interactive" |
| 4 | + |
| 5 | +branding: |
| 6 | + icon: "moon" |
| 7 | + color: "blue" |
| 8 | + |
| 9 | +inputs: |
| 10 | + ai-api-key: |
| 11 | + description: "API key for AI service (OpenAI, Anthropic, Google, etc.)" |
| 12 | + required: true |
| 13 | + |
| 14 | + git-api-key: |
| 15 | + description: "API key for GitHub (you can use GITHUB_TOKEN)" |
| 16 | + required: true |
| 17 | + |
| 18 | + pr-number: |
| 19 | + description: "Pull request number to review" |
| 20 | + required: true |
| 21 | + |
| 22 | + model: |
| 23 | + description: "AI model to use (e.g. gpt-4o, claude-3-5-sonnet-latest, gemini-2.0-flash)" |
| 24 | + required: false |
| 25 | + default: "gpt-5" |
| 26 | + |
| 27 | + version: |
| 28 | + description: "LGTM AI version (latest, v0.7.2, etc.)" |
| 29 | + required: false |
| 30 | + default: "latest" |
| 31 | + |
| 32 | + publish: |
| 33 | + description: "Whether to publish the review as PR comments" |
| 34 | + required: false |
| 35 | + default: "true" |
| 36 | + |
| 37 | + exclude: |
| 38 | + description: "File patterns to exclude (e.g. '*.md *.json package-lock.json')" |
| 39 | + required: false |
| 40 | + default: "" |
| 41 | + |
| 42 | + config: |
| 43 | + description: "Path to lgtm.toml configuration file (e.g. '.lgtm.toml')" |
| 44 | + required: false |
| 45 | + default: "" |
| 46 | + |
| 47 | +runs: |
| 48 | + using: "composite" |
| 49 | + steps: |
| 50 | + - name: Run LGTM AI Review |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + # Build arguments as an array for safety (avoids word-splitting issues) |
| 54 | + ARGS=( |
| 55 | + review |
| 56 | + --pr-url "https://github.com/${{ github.repository }}/pull/${{ inputs.pr-number }}" |
| 57 | + --git-api-key "${{ inputs.git-api-key }}" |
| 58 | + --ai-api-key "${{ inputs.ai-api-key }}" |
| 59 | + --model "${{ inputs.model }}" |
| 60 | + ) |
| 61 | +
|
| 62 | + # Optional flags |
| 63 | + if [ "${{ inputs.publish }}" = "true" ]; then |
| 64 | + ARGS+=(--publish) |
| 65 | + fi |
| 66 | +
|
| 67 | + if [ -n "${{ inputs.exclude }}" ]; then |
| 68 | + ARGS+=(--exclude "${{ inputs.exclude }}") |
| 69 | + fi |
| 70 | +
|
| 71 | + if [ -n "${{ inputs.config }}" ]; then |
| 72 | + ARGS+=(--config "${{ inputs.config }}") |
| 73 | + fi |
| 74 | +
|
| 75 | + # Verbose mode |
| 76 | + ARGS+=(-v) |
| 77 | +
|
| 78 | + docker run --rm \ |
| 79 | + -v "${{ github.workspace }}:/workspace" \ |
| 80 | + -w /workspace \ |
| 81 | + elementsinteractive/lgtm-ai:${{ inputs.version }} \ |
| 82 | + "${ARGS[@]}" |
0 commit comments