Test AI PR comment #13
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 repo | |
| - 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 | |
| - name: Collect git diff | |
| run: | | |
| git fetch origin main | |
| git diff origin/main...HEAD > diff.txt | |
| # 5️⃣ Prepare payload JSON | |
| - name: Prepare payload | |
| run: | | |
| jq -n \ | |
| --rawfile diff diff.txt \ | |
| '{ diff: $diff }' > payload.json | |
| # 6️⃣ Base64 encode payload (STRICT FIX) | |
| - name: Base64 encode payload | |
| run: | | |
| base64 -w 0 payload.json > payload.b64 | |
| # 7️⃣ Invoke Lambda (CRITICAL FIX: JSON output enforced) | |
| - name: Invoke Lambda for AI Code Review | |
| run: | | |
| aws lambda invoke \ | |
| --function-name ai-code-review-lambda \ | |
| --cli-binary-format raw-in-base64-out \ | |
| --payload "$(cat payload.b64)" \ | |
| --output json \ | |
| response.json | |
| # 8️⃣ Show Lambda raw response (debug-safe) | |
| - name: Show AI Code Review Result | |
| run: | | |
| cat response.json | |
| # 9️⃣ Extract PDF URL (FINAL FIX) | |
| - name: Extract PDF URL | |
| run: | | |
| jq -r '.body | fromjson | .pdf_url' response.json > pdf_url.txt | |
| # 🔟 Post PDF link as PR comment | |
| - name: Post PDF link as PR comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const url = fs.readFileSync('pdf_url.txt', 'utf8').trim(); | |
| github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: `🧠 **AI Code Review Report**\n\n📄 PDF: ${url}` | |
| }); |