Skip to content

Commit 15c0723

Browse files
owtaylorclaude
andauthored
Skip functional test workflow for non-trigger issue comments (#471)
Add a job-level `if` condition to skip the check-authorization job when an issue_comment event doesn't match a trigger command (/test-functional or /retest). This prevents noisy failed workflow runs from bot comments and regular PR discussion. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3a682c8 commit 15c0723

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

.github/workflows/functional-tests.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ jobs:
1919
check-authorization:
2020
name: Check Authorization
2121
runs-on: ubuntu-latest
22+
if: >-
23+
github.event_name != 'issue_comment' ||
24+
(github.event.issue.pull_request &&
25+
(startsWith(github.event.comment.body, '/test-functional') ||
26+
startsWith(github.event.comment.body, '/retest')))
2227
outputs:
2328
authorized: ${{ steps.check.outputs.authorized }}
2429
steps:
@@ -34,6 +39,18 @@ jobs:
3439
if (eventName === 'push' || eventName === 'workflow_dispatch') {
3540
authorized = true;
3641
} else {
42+
if (eventName === 'issue_comment') {
43+
if (!context.payload.issue.pull_request) {
44+
core.setFailed('issue_comment event on a non-PR issue should have been filtered by job condition');
45+
return;
46+
}
47+
const body = context.payload.comment.body;
48+
if (!/^\/(test-functional|retest)/.test(body)) {
49+
core.setFailed('issue_comment without trigger command should have been filtered by job condition');
50+
return;
51+
}
52+
}
53+
3754
try {
3855
const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
3956
owner: context.repo.owner,
@@ -43,14 +60,7 @@ jobs:
4360
4461
const role = permission.permission; // admin, write, maintain, read, none
4562
if (['admin', 'write', 'maintain'].includes(role)) {
46-
if (eventName === 'pull_request_target') {
47-
authorized = true;
48-
} else if (eventName === 'issue_comment' && context.payload.issue.pull_request) {
49-
const body = context.payload.comment.body;
50-
if (/^\/(test-functional|retest)/.test(body)) {
51-
authorized = true;
52-
}
53-
}
63+
authorized = true;
5464
}
5565
} catch (error) {
5666
core.error(`Failed to check permissions for ${user}: ${error.message}`);

0 commit comments

Comments
 (0)