-
Notifications
You must be signed in to change notification settings - Fork 2.5k
78 lines (70 loc) · 2.35 KB
/
Copy pathstyle.yml
File metadata and controls
78 lines (70 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Style Check
on:
pull_request:
paths:
- ".github/workflows/**"
- "src/**.cpp"
- "src/**.h"
jobs:
stylecheck:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Run style check
id: style-check
run: echo "reviews=$(python3 scripts/build/style.py --base-sha ${{ github.event.pull_request.base.sha }} | jq -s -c .)" >> $GITHUB_OUTPUT
- name: Delete previous bot review comments
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = context.payload.pull_request;
const comments = await github.paginate(
github.rest.pulls.listReviewComments,
{
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
per_page: 100,
}
);
for (const comment of comments) {
if (comment.user && comment.user.login === "github-actions[bot]") {
await github.rest.pulls.deleteReviewComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id
});
}
}
- name: Post review comments
uses: actions/github-script@v8
id: post-comments
env:
REVIEWS: ${{ steps.style-check.outputs.reviews }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const reviews = JSON.parse(process.env.REVIEWS || "[]");
if (reviews.length === 0) {
console.info("Review list empty.");
return;
}
console.debug("Reviews: ", reviews);
for (const r of reviews) {
await github.rest.pulls.createReviewComment({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
body: r.body,
commit_id: context.sha,
path: r.path,
side: "RIGHT",
line: r.line,
});
}