Skip to content

ai review test

ai review test #6

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 'pending-ai-review' label exists
id: check_label
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labels = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
});
const hasLabel = labels.data.some(label => label.name === 'pending-ai-review');
console.log(`Labels: ${labels.data.map(l => l.name).join(', ')}`);
core.setOutput('has_label', hasLabel);
- name: Add label if missing
if: steps.check_label.outputs.has_label == 'false'
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: pending-ai-review
- name: Stop if only labeling
if: steps.check_label.outputs.has_label == '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