Files
lazyjournal/.github/workflows/ai-code-review.yml
2026-10-28 13:38:36 +03:00

79 lines
2.5 KiB
YAML

name: "[AI] Code review"
on:
workflow_dispatch:
inputs:
Prompt:
description: "Prompt"
required: true
default: ""
PR:
description: "Create PR"
default: false
type: boolean
Branch:
description: "Branch for current or new PR"
required: true
default: "ai/code-review"
Title:
description: "Title for PR"
required: true
default: "[AI] Code review"
permissions:
contents: write
pull-requests: write
jobs:
opencode-review:
runs-on: ubuntu-latest
steps:
- name: Build parameters to github summary
shell: bash
run: |
echo "## Build parameters" >> $GITHUB_STEP_SUMMARY
echo "- **Prompt**: ${{ github.event.inputs.Prompt }}" >> $GITHUB_STEP_SUMMARY
echo "- **PR**: ${{ github.event.inputs.PR == 'true' && '✅ true' || '❌ false' }}" >> $GITHUB_STEP_SUMMARY
echo "- **Branch**: ${{ github.event.inputs.Branch }}" >> $GITHUB_STEP_SUMMARY
echo "- **Title**: ${{ github.event.inputs.Title }}" >> $GITHUB_STEP_SUMMARY
- name: Clone repository
uses: actions/checkout@v7
with:
ref: ${{ github.event.inputs.Branch }}
- name: Install Go 1.26
uses: actions/setup-go@v7
with:
go-version: 1.27.0
- name: Install opencode
run: curl -fsSL https://opencode.ai/v2/install | bash
- name: Add opencode to PATH
run: echo "$HOME/.opencode/bin" >> $GITHUB_PATH
- name: Run opencode in auto mode
run: opencode run "${{ github.event.inputs.Prompt }}" --auto --agent build
- name: Git diff to github summary
run: |
echo "## Git diff" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`diff" >> $GITHUB_STEP_SUMMARY
git diff >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
- name: Create PR
if: ${{ github.event.inputs.PR == 'true' }}
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "code review from build ${{ github.run_number }}"
base: main
branch: ${{ github.event.inputs.Branch }}
title: "${{ github.event.inputs.Title }}"
body: |
Prompt:
> ${{ inputs.Prompt }}
add-paths: .