Skip to content

auto review

auto review #1

Workflow file for this run

name: AI Code Review on PR
on:
pull_request_target:
types: [opened, synchronize, labeled]
permissions:
contents: read
pull-requests: write
jobs:
ai-review:
runs-on: ubuntu-latest
steps:
- name: Check if label exists
id: check_label
uses: actions-ecosystem/action-get-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Add label if missing
if: contains(steps.check_label.outputs.labels, 'pending-ai-review') == false
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: pending-ai-review
- name: Stop if only labeling
if: contains(steps.check_label.outputs.labels, 'pending-ai-review') == false
run: |
echo "Label added. Exiting."
exit 0
- name: 🐍 Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: 📦 Install dependencies
run: pip install openai PyGithub
- name: ✅ Checkout PR
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: 🤖 Run AI code review
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_API_ENDPOINT: ${{ secrets.OPENAI_API_ENDPOINT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: python .github/scripts/ai_review.py