This commit is contained in:
53
.github/workflows/ai-review.yml
vendored
53
.github/workflows/ai-review.yml
vendored
@@ -8,21 +8,22 @@ jobs:
|
|||||||
review:
|
review:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: python:3.11-bookworm
|
image: node:20-bookworm
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Install system deps + Python 3.11
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Show Python
|
|
||||||
run: python --version
|
|
||||||
|
|
||||||
- name: Install system deps (git + curl)
|
|
||||||
run: |
|
run: |
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y --no-install-recommends git curl ca-certificates
|
apt-get install -y --no-install-recommends \
|
||||||
|
git curl ca-certificates \
|
||||||
|
python3.11 python3.11-venv python3-pip
|
||||||
|
ln -sf /usr/bin/python3.11 /usr/local/bin/python
|
||||||
|
python --version
|
||||||
|
node --version
|
||||||
git --version
|
git --version
|
||||||
curl --version
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Create venv and install project
|
- name: Create venv and install project
|
||||||
run: |
|
run: |
|
||||||
@@ -53,30 +54,8 @@ jobs:
|
|||||||
--head "${{ github.head_ref }}" \
|
--head "${{ github.head_ref }}" \
|
||||||
--format json > review.json
|
--format json > review.json
|
||||||
|
|
||||||
- name: Post PR comment with findings
|
# Temporarily remove github-script; it also needs GitHub env
|
||||||
uses: actions/github-script@v6
|
- name: Show result
|
||||||
with:
|
run: |
|
||||||
script: |
|
ls -la
|
||||||
const fs = require('fs');
|
head -c 2000 review.json || true
|
||||||
let body = '{}';
|
|
||||||
try { body = fs.readFileSync('review.json', 'utf8'); } catch (e) {
|
|
||||||
body = JSON.stringify({ error: 'missing-review', message: String(e) });
|
|
||||||
}
|
|
||||||
let parsed = {};
|
|
||||||
try { parsed = JSON.parse(body); } catch (e) {
|
|
||||||
parsed = { error: 'invalid-json', raw: body };
|
|
||||||
}
|
|
||||||
const findings = parsed.findings || [];
|
|
||||||
const summary = findings.length === 0
|
|
||||||
? 'AI Reviewer: no findings.'
|
|
||||||
: `AI Reviewer found ${findings.length} findings.`;
|
|
||||||
const commentBody =
|
|
||||||
`${summary}\n\n<details><summary>Full JSON</summary>\n\n` +
|
|
||||||
'```json\n' + JSON.stringify(parsed, null, 2) + '\n```\n' +
|
|
||||||
'</details>';
|
|
||||||
await github.rest.issues.createComment({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
issue_number: context.issue.number,
|
|
||||||
body: commentBody,
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user