trigger-workflow
Initiate a workflow run in a GitHub repository using specified branch, tag, or commit reference to automate CI/CD processes and deployment tasks.
Instructions
Trigger a workflow run in a GitHub repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inputs | No | Workflow inputs | |
| owner | Yes | Repository owner | |
| ref | Yes | Git reference (branch, tag, SHA) | |
| repo | Yes | Repository name | |
| workflow_id | Yes | Workflow ID or file name |
Implementation Reference
- src/tools/repository.ts:367-386 (handler)The core handler function that parses arguments using TriggerWorkflowSchema, authenticates with GitHub API, and dispatches the workflow run using actions.createWorkflowDispatch.export async function triggerWorkflow(args: unknown): Promise<any> { const { owner, repo, workflow_id, ref, inputs } = TriggerWorkflowSchema.parse(args); const github = getGitHubApi(); return tryCatchAsync(async () => { const { data } = await github.getOctokit().actions.createWorkflowDispatch({ owner, repo, workflow_id, ref, inputs, }); return { success: true, message: `Workflow dispatch event created for workflow ${workflow_id} on ref ${ref}`, data, }; }, 'Failed to trigger workflow'); }
- src/utils/validation.ts:257-261 (schema)Zod schema for validating trigger-workflow inputs, extending OwnerRepoSchema (owner/repo required). Used in the handler for parsing.export const TriggerWorkflowSchema = OwnerRepoSchema.extend({ workflow_id: z.union([z.string(), z.number()]), ref: z.string().min(1, 'Git reference is required'), inputs: z.record(z.string()).optional(), });
- src/server.ts:356-386 (registration)Tool registration in the ListToolsRequestSchema handler, defining name, description, and inputSchema for the MCP protocol.{ name: 'trigger-workflow', description: 'Trigger a workflow run in a GitHub repository', inputSchema: { type: 'object', properties: { owner: { type: 'string', description: 'Repository owner', }, repo: { type: 'string', description: 'Repository name', }, workflow_id: { type: ['string', 'number'], description: 'Workflow ID or file name', }, ref: { type: 'string', description: 'Git reference (branch, tag, SHA)', }, inputs: { type: 'object', description: 'Workflow inputs', }, }, required: ['owner', 'repo', 'workflow_id', 'ref'], additionalProperties: false, }, },
- src/server.ts:1187-1189 (registration)Dispatch in the CallToolRequestSchema switch statement that routes calls to the triggerWorkflow handler.case 'trigger-workflow': result = await triggerWorkflow(parsedArgs); break;