Skip to content

chore(deps): bump git2 from 0.18.3 to 0.20.4 #3

chore(deps): bump git2 from 0.18.3 to 0.20.4

chore(deps): bump git2 from 0.18.3 to 0.20.4 #3

Workflow file for this run

name: DiffScope Review
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
concurrency:
group: diffscope-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
review:
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository && !github.event.pull_request.draft
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Get PR diff
id: diff
run: |
git fetch origin ${{ github.base_ref }} --depth=1
git diff origin/${{ github.base_ref }}...HEAD > pr.diff
- name: Run DiffScope
uses: docker://ghcr.io/haasonsaas/diffscope:latest
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
with:
args: review --diff pr.diff --output-format json --output comments.json
- name: Post comments
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const comments = JSON.parse(fs.readFileSync('comments.json', 'utf8'));
const headSha = context.payload.pull_request.head.sha;
const fallback = [];
for (const comment of comments) {
if (!comment.file_path || !comment.line_number || comment.line_number < 1) {
continue;
}
try {
await github.rest.pulls.createReviewComment({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
body: `**${comment.severity}**: ${comment.content}`,
commit_id: headSha,
path: comment.file_path,
line: comment.line_number,
side: "RIGHT"
});
} catch (error) {
fallback.push(`- **${comment.severity}** ${comment.file_path}:${comment.line_number} ${comment.content}`);
}
}
if (fallback.length > 0) {
const body = [
"Some review comments could not be placed inline and are listed below:",
"",
...fallback.slice(0, 100)
].join("\\n");
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});
}