-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (59 loc) · 1.96 KB
/
Copy pathdrykit-example.yml
File metadata and controls
71 lines (59 loc) · 1.96 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
# drykit check
# Drop this file into .github/workflows/ to run drykit on every PR.
# Posts a markdown report as a PR comment.
name: drykit check
on:
pull_request:
types: [opened, synchronize]
jobs:
check:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm install -g drykit
- name: Scan project
run: drykit scan
- name: Run drykit check
id: check
run: drykit check --report-file /tmp/drykit-report.md --ci
continue-on-error: true
- name: Post PR comment
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const reportPath = '/tmp/drykit-report.md';
if (!fs.existsSync(reportPath)) return;
const body = fs.readFileSync(reportPath, 'utf8');
if (!body.trim()) return;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c => c.body.includes('drykit report'));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
- name: Fail if issues found
if: steps.check.outcome == 'failure'
run: exit 1