Skip to content

Commit d29754c

Browse files
justaddcoffeeclaude
andcommitted
Add workflow_dispatch trigger to manually re-run AI agent on issues/PRs
This allows manually triggering the AI agent workflow for specific issues or PRs via GitHub UI or CLI, useful for re-processing existing issues after adding new allowed users to the controllers list. Usage: gh workflow run ai-agent.yml -f item-type=issue -f item-number=69 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2837dac commit d29754c

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

.github/workflows/ai-agent.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ on:
99
types: [opened, edited]
1010
pull_request_review_comment:
1111
types: [created, edited]
12+
workflow_dispatch:
13+
inputs:
14+
item-type:
15+
description: 'Type of item (issue or pull_request)'
16+
required: true
17+
type: choice
18+
options:
19+
- issue
20+
- pull_request
21+
item-number:
22+
description: 'Issue or PR number'
23+
required: true
24+
type: number
1225

1326
jobs:
1427
check-mention:
@@ -49,7 +62,29 @@ jobs:
4962
let itemType = '';
5063
let itemNumber = 0;
5164
52-
if (context.eventName === 'issues') {
65+
if (context.eventName === 'workflow_dispatch') {
66+
// Manual trigger - fetch the issue/PR from GitHub API
67+
itemType = context.payload.inputs['item-type'];
68+
itemNumber = parseInt(context.payload.inputs['item-number']);
69+
70+
if (itemType === 'issue') {
71+
const issue = await github.rest.issues.get({
72+
owner: context.repo.owner,
73+
repo: context.repo.repo,
74+
issue_number: itemNumber
75+
});
76+
content = issue.data.body || '';
77+
userLogin = context.actor; // Use the person who triggered the workflow
78+
} else if (itemType === 'pull_request') {
79+
const pr = await github.rest.pulls.get({
80+
owner: context.repo.owner,
81+
repo: context.repo.repo,
82+
pull_number: itemNumber
83+
});
84+
content = pr.data.body || '';
85+
userLogin = context.actor; // Use the person who triggered the workflow
86+
}
87+
} else if (context.eventName === 'issues') {
5388
content = context.payload.issue.body || '';
5489
userLogin = context.payload.issue.user.login;
5590
itemType = 'issue';

0 commit comments

Comments
 (0)