Test AI PR comment #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: AI Code Review | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| code-review: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1️⃣ Checkout repository | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # 2️⃣ Configure AWS credentials | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| # 3️⃣ Install jq | |
| - name: Install jq | |
| run: sudo apt-get update && sudo apt-get install -y jq | |
| # 4️⃣ Collect git diff (PR → main) | |
| - name: Collect git diff | |
| run: | | |
| git fetch origin main | |
| git diff origin/main...HEAD > diff.txt | |
| # 5️⃣ Prepare JSON payload (NO base64) | |
| - name: Prepare payload | |
| run: | | |
| jq -Rs '{diff: .}' diff.txt > payload.json | |
| cat payload.json | |
| # 6️⃣ Invoke Lambda (RAW JSON — THIS IS THE FIX) | |
| - name: Invoke Lambda for AI Code Review | |
| run: | | |
| aws lambda invoke \ | |
| --function-name code-review-lambda \ | |
| --cli-binary-format raw-in-base64-out \ | |
| --payload file://payload.json \ | |
| response.json | |
| cat response.json | |
| # 7️⃣ Extract PDF URL safely | |
| - name: Extract PDF URL | |
| run: | | |
| jq -r '.body | fromjson | .pdf_url' response.json > pdf_url.txt | |
| cat pdf_url.txt | |
| # 8️⃣ Post PDF link as PR comment | |
| - name: Post PDF link as PR comment | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| PDF_URL=$(cat pdf_url.txt) | |
| gh pr comment ${{ github.event.pull_request.number }} \ | |
| --body "📄 **AI Code Review Report** | |
| 🔗 $PDF_URL" |