Skip to content

Commit c40eb42

Browse files
justin808claude
andcommitted
Expand command detection to multiple prefixes
Extended the workflow to detect commands starting with: - /ci (e.g., /ci, /ci-run, /ci-test) - /run (e.g., /run, /run-tests) - /stop (e.g., /stop, /stop-ci) - /delete (e.g., /delete) - /deploy (e.g., /deploy) - /help (e.g., /help) Benefits: - Catches more common command attempts users might try - Still only detects commands at the beginning of comments or after newlines - Excludes valid commands (/run-skipped-ci, /stop-run-skipped-ci) - Simple pattern matching - easy to maintain Testing shows 100% pass rate across all scenarios including: - All valid commands correctly ignored - All common command prefixes correctly detected - Commands in middle of text correctly ignored - URLs correctly ignored 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent caec799 commit c40eb42

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

.github/workflows/detect-invalid-ci-commands.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ on:
66

77
jobs:
88
detect-invalid-commands:
9-
# Only run on PR comments that contain /ci commands but don't match valid commands
9+
# Only run on PR comments that contain potential commands but don't match valid commands
1010
if: |
1111
github.event.issue.pull_request &&
12-
contains(github.event.comment.body, '/ci') &&
12+
(
13+
contains(github.event.comment.body, '/ci') ||
14+
contains(github.event.comment.body, '/run') ||
15+
contains(github.event.comment.body, '/stop') ||
16+
contains(github.event.comment.body, '/delete') ||
17+
contains(github.event.comment.body, '/deploy') ||
18+
contains(github.event.comment.body, '/help')
19+
) &&
1320
!contains(github.event.comment.body, '/run-skipped-ci') &&
1421
!contains(github.event.comment.body, '/stop-run-skipped-ci')
1522
runs-on: ubuntu-22.04
@@ -24,13 +31,13 @@ jobs:
2431
script: |
2532
const comment = context.payload.comment.body;
2633
27-
// Pattern to detect /ci* commands at the start of a line
28-
// Matches: /ci, /ci-run, /ci-test, etc. at beginning of comment or after newline
29-
const ciCommandPattern = /(?:^|\n)\s*(\/ci[\w-]*)/gi;
30-
const matches = [...comment.matchAll(ciCommandPattern)];
34+
// Pattern to detect potential command attempts at the start of a line
35+
// Matches: /ci*, /run*, /stop*, /delete*, /deploy*, /help* at beginning or after newline
36+
const commandPattern = /(?:^|\n)\s*(\/(ci|run|stop|delete|deploy|help)[\w-]*)/gi;
37+
const matches = [...comment.matchAll(commandPattern)];
3138
3239
if (matches.length === 0) {
33-
console.log('No /ci commands found at line start');
40+
console.log('No potential commands found at line start');
3441
return { shouldRespond: false };
3542
}
3643
@@ -43,7 +50,7 @@ jobs:
4350
.filter(cmd => !validCommands.includes(cmd));
4451
4552
if (invalidCommands.length > 0) {
46-
console.log('Found invalid /ci commands:', invalidCommands);
53+
console.log('Found invalid commands:', invalidCommands);
4754
return {
4855
shouldRespond: true,
4956
invalidCommands: invalidCommands

0 commit comments

Comments
 (0)