Skip to content

Add structured checklist and recommendation to AI reviews #5

Add structured checklist and recommendation to AI reviews

Add structured checklist and recommendation to AI reviews #5

name: AI Code Reviewer
on:
pull_request:
types: [labeled]
jobs:
comprehensive-review:
name: 🤖 AI Code Review
runs-on: ubuntu-latest
if: github.event.action == 'labeled' && github.event.label.name == 'ai_code_review'
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Get PR diff
run: |
# Fetch the base branch (works for any target branch, not just main)
git fetch origin ${{ github.event.pull_request.base.ref }}
git diff origin/${{ github.event.pull_request.base.ref }}...HEAD --no-color > diff.txt
- name: AI Code Review
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
AI_MODEL: z-ai/glm-4.6
AI_TEMPERATURE: 0.1
AI_MAX_TOKENS: 2000
MAX_DIFF_SIZE: 800000
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO_FULL_NAME: ${{ github.repository }}
run: |
# Run the AI reviewer and post the comment directly via stdin
# If the script fails, the error message will be posted as a comment
cat diff.txt | bash ai-reviewer.sh | gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} -F - || {
echo "⚠️ AI Code Review failed. Check the workflow logs for details."
exit 1
}
- name: Cleanup
if: always()
run: |
rm -f diff.txt