Skip to content

Commit 5a2ad4a

Browse files
fix: Refine PR gate conditions and update verification messages for Agent attestation checkboxes
1 parent 06706ec commit 5a2ad4a

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

.github/workflows/coding-agent-pr-gate.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Coding-Agent PR Gate
22

33
on:
44
pull_request:
5-
types: [opened, edited, reopened, ready_for_review, synchronize, labeled, unlabeled]
5+
types: [opened, edited, reopened, ready_for_review, labeled, unlabeled]
66

77
permissions: {}
88

@@ -13,12 +13,18 @@ concurrency:
1313
jobs:
1414
checklist-gate:
1515
name: PR body checklist gate
16-
if: github.event.pull_request.draft == false && contains(github.event.pull_request.labels.*.name, 'coding-agent')
16+
if: >-
17+
github.event.pull_request.draft == false &&
18+
(
19+
contains(github.event.pull_request.labels.*.name, 'coding-agent') ||
20+
github.event.pull_request.user.login == 'Copilot' ||
21+
github.actor == 'copilot-swe-agent[bot]'
22+
)
1723
runs-on: ubuntu-latest
1824
permissions:
1925
pull-requests: read
2026
steps:
21-
- name: Verify every checkbox in PR body is ticked
27+
- name: Verify every Agent attestation checkbox is ticked
2228
uses: actions/github-script@v7
2329
with:
2430
script: |
@@ -30,23 +36,35 @@ jobs:
3036
.replace(/<!--[\s\S]*?-->/g, '')
3137
.replace(/```[\s\S]*?```/g, '');
3238
33-
const lines = stripped.split(/\r?\n/);
39+
// The gate only scans the `## Agent attestation` section. Other sections
40+
// (Type of change, Required reading consulted) intentionally allow partial
41+
// ticking — only the attestation checkboxes are gating.
42+
const sectionMatch = stripped.match(/^##\s+Agent attestation\s*$([\s\S]*?)(?=^##\s|\z)/m);
43+
if (!sectionMatch) {
44+
core.setFailed(
45+
`PR body is missing the '## Agent attestation' section. ` +
46+
`Coding-agent PRs must include the attestation block from PULL_REQUEST_TEMPLATE.md.`
47+
);
48+
return;
49+
}
50+
51+
const lines = sectionMatch[1].split(/\r?\n/);
3452
const unchecked = [];
3553
for (let i = 0; i < lines.length; i++) {
3654
const m = lines[i].match(/^\s*[-*]\s+\[\s\]\s+(.*)$/);
3755
if (m) {
38-
unchecked.push(`L${i + 1}: ${m[1]}`);
56+
unchecked.push(m[1]);
3957
}
4058
}
4159
4260
if (unchecked.length > 0) {
4361
core.setFailed(
44-
`PR body has ${unchecked.length} unticked checkbox(es). ` +
45-
`The 'coding-agent' label requires every checkbox to be ticked before merge.\n\n` +
62+
`Agent attestation has ${unchecked.length} unticked checkbox(es). ` +
63+
`Coding-agent PRs require every attestation box to be ticked before merge.\n\n` +
4664
unchecked.map(u => ` - ${u}`).join('\n') +
47-
`\n\nTick each box in the PR description, or remove the 'coding-agent' label if this PR was not produced by the agent.`
65+
`\n\nTick each box in the '## Agent attestation' section. If this PR was not produced by an agent, remove the 'coding-agent' label (the gate also fires automatically for the Copilot bot author).`
4866
);
4967
return;
5068
}
5169
52-
core.info('All checkboxes in the PR body are ticked. Gate passes.');
70+
core.info('All Agent attestation checkboxes are ticked. Gate passes.');

0 commit comments

Comments
 (0)