-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (41 loc) · 1.77 KB
/
coding-agent-pr-gate.yml
File metadata and controls
48 lines (41 loc) · 1.77 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
name: Coding-Agent PR Gate
on:
pull_request:
types: [opened, edited, reopened, ready_for_review, synchronize, labeled, unlabeled]
permissions: {}
jobs:
checklist-gate:
name: PR body checklist gate
if: github.event.pull_request.draft == false && contains(github.event.pull_request.labels.*.name, 'coding-agent')
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- name: Verify every checkbox in PR body is ticked
uses: actions/github-script@v7
with:
script: |
const body = context.payload.pull_request.body || '';
// Strip HTML comments — guidance comments may contain unticked example boxes.
// Then strip fenced code blocks — pasted command output must not trip the gate.
const stripped = body
.replace(/<!--[\s\S]*?-->/g, '')
.replace(/```[\s\S]*?```/g, '');
const lines = stripped.split(/\r?\n/);
const unchecked = [];
for (let i = 0; i < lines.length; i++) {
const m = lines[i].match(/^\s*[-*]\s+\[\s\]\s+(.*)$/);
if (m) {
unchecked.push(`L${i + 1}: ${m[1]}`);
}
}
if (unchecked.length > 0) {
core.setFailed(
`PR body has ${unchecked.length} unticked checkbox(es). ` +
`The 'coding-agent' label requires every checkbox to be ticked before merge.\n\n` +
unchecked.map(u => ` - ${u}`).join('\n') +
`\n\nTick each box in the PR description, or remove the 'coding-agent' label if this PR was not produced by the agent.`
);
return;
}
core.info('All checkboxes in the PR body are ticked. Gate passes.');