DispatchOps
DispatchOps enables manual workflow execution via the GitHub Actions UI or CLI, perfect for on-demand tasks, testing, and workflows that need human judgment about timing. The workflow_dispatch trigger lets you run workflows with custom inputs whenever needed.
Use DispatchOps for research tasks, operational commands, testing workflows during development, debugging production issues, or any task that doesn’t fit a schedule or event trigger.
How Workflow Dispatch Works
Section titled “How Workflow Dispatch Works”Workflows with workflow_dispatch can be triggered manually rather than waiting for events like issues, pull requests, or schedules.
Basic Syntax
Section titled “Basic Syntax”Add workflow_dispatch: to the on: section in your workflow frontmatter:
on: workflow_dispatch:With Input Parameters
Section titled “With Input Parameters”Define inputs to customize workflow behavior at runtime:
on: workflow_dispatch: inputs: topic: description: 'Research topic' required: true type: string priority: description: 'Task priority' required: false type: choice options: - low - medium - high default: mediumSupported input types:
string- Free-form text inputboolean- True/false checkboxchoice- Dropdown selection with predefined optionsenvironment- Repository environment selector
Security Model
Section titled “Security Model”Permission Requirements
Section titled “Permission Requirements”Manual workflow execution respects the same security model as other triggers:
- Repository permissions - User must have write access or higher to trigger workflows
- Role-based access - Use the
roles:field to restrict who can run workflows:
on: workflow_dispatch:roles: [admin, maintainer]- Bot authorization - Use the
bots:field to allow specific bot accounts:
on: workflow_dispatch:bots: ["dependabot[bot]", "github-actions[bot]"]Fork Protection
Section titled “Fork Protection”Unlike issue/PR triggers, workflow_dispatch only executes in the repository where it’s defined—forks cannot trigger workflows in the parent repository. This provides inherent protection against fork-based attacks.
Environment Approval Gates
Section titled “Environment Approval Gates”Require manual approval before execution using GitHub environment protection rules:
on: workflow_dispatch:manual-approval: productionConfigure approval rules, required reviewers, and wait timers in repository Settings → Environments. See GitHub’s environment documentation for setup details.
Running Workflows from GitHub.com
Section titled “Running Workflows from GitHub.com”Via Actions Tab
Section titled “Via Actions Tab”- Navigate to your repository on GitHub.com
- Click the Actions tab
- Select the workflow from the left sidebar
- Click the Run workflow dropdown button
- Select the branch to run from (default: main)
- Fill in any required inputs
- Click the Run workflow button
The workflow will execute immediately, and you can watch progress in the Actions tab.
Finding Runnable Workflows
Section titled “Finding Runnable Workflows”Only workflows with workflow_dispatch: appear in the “Run workflow” dropdown. If your workflow isn’t listed:
- Verify
workflow_dispatch:exists in theon:section - Ensure the workflow has been compiled and pushed to GitHub
- Check that the
.lock.ymlfile exists in.github/workflows/
Running Workflows with CLI
Section titled “Running Workflows with CLI”The gh aw run command provides a faster way to trigger workflows from the command line.
Basic Usage
Section titled “Basic Usage”gh aw run workflowThe command:
- Finds the workflow by name (e.g.,
researchmatchesresearch.md) - Validates it has
workflow_dispatch:trigger - Triggers execution via GitHub Actions API
- Returns immediately with the run URL
With Input Parameters
Section titled “With Input Parameters”Pass inputs using the --raw-field or -f flag in key=value format:
gh aw run research --raw-field topic="quantum computing"Multiple inputs:
gh aw run scout \ --raw-field topic="AI safety research" \ --raw-field priority=highWait for Completion
Section titled “Wait for Completion”Monitor workflow execution and wait for results:
gh aw run research --raw-field topic="AI agents" --waitThe --wait flag:
- Monitors workflow progress in real-time
- Shows status updates
- Waits for completion before returning
- Exits with success/failure code based on workflow result
Branch Selection
Section titled “Branch Selection”Run workflows from specific branches:
gh aw run research --ref feature-branchRunning Remote Workflows
Section titled “Running Remote Workflows”Execute workflows from other repositories:
gh aw run workflow --repo owner/repositoryVerbose Output
Section titled “Verbose Output”See detailed execution information:
gh aw run research --raw-field topic="AI" --verboseDeclaring and Referencing Inputs
Section titled “Declaring and Referencing Inputs”Declaring Inputs in Frontmatter
Section titled “Declaring Inputs in Frontmatter”Define inputs in the workflow_dispatch section with clear descriptions:
on: workflow_dispatch: inputs: analysis_depth: description: 'How deep should the analysis go?' required: true type: choice options: - surface - detailed - comprehensive default: detailed
include_examples: description: 'Include code examples in the report' required: false type: boolean default: true
max_results: description: 'Maximum number of results to return' required: false type: string default: '10'Best practices:
- Use descriptive
descriptiontext to guide users - Set sensible
defaultvalues for optional inputs - Use
choicetype to constrain options and prevent invalid values - Mark truly required inputs with
required: true
Referencing Inputs in Markdown
Section titled “Referencing Inputs in Markdown”Access input values using GitHub Actions expression syntax:
---on: workflow_dispatch: inputs: topic: description: 'Research topic' required: true type: string depth: description: 'Analysis depth' type: choice options: - brief - detailed default: briefpermissions: contents: readsafe-outputs: create-discussion:---
# Research Assistant
Research the following topic: "${{ github.event.inputs.topic }}"
Analysis depth requested: ${{ github.event.inputs.depth }}
Provide a ${{ github.event.inputs.depth }} analysis with key findings and recommendations.Expression syntax:
- Use
${{ github.event.inputs.INPUT_NAME }}to reference input values - Inputs are available throughout the entire workflow markdown
- Values are interpolated at workflow compile time into the GitHub Actions YAML
Conditional Logic Based on Inputs
Section titled “Conditional Logic Based on Inputs”Use Handlebars conditionals to change behavior based on input values:
{{#if (eq github.event.inputs.include_code "true")}}Include actual code snippets in your analysis.{{else}}Describe code patterns without including actual code.{{/if}}
{{#if (eq github.event.inputs.priority "high")}}URGENT: Prioritize speed over completeness.{{/if}}Development Pattern: Branch Testing
Section titled “Development Pattern: Branch Testing”Testing Workflow Changes
Section titled “Testing Workflow Changes”When developing workflows in a feature branch, add workflow_dispatch: for testing before merging to main:
# 1. Develop in feature branchgit checkout -b feature/improve-workflow# Edit .github/workflows/research.md and add workflow_dispatch
# 2. Test in isolation firstgh aw trial ./research.md --raw-field topic="test query"
# 3. For in-repo testing, temporarily push to maingit checkout maingit cherry-pick <commit-sha>git push origin main
# 4. Test from your branchgit checkout feature/improve-workflowgh aw run research --ref feature/improve-workflow
# 5. Iterate, then create PR when satisfiedgh pr create --title "Improve workflow"The workflow runs with your branch’s code and state. Safe outputs (issues, PRs, comments) are created in your branch context. Use trial mode for completely isolated testing without affecting the production repository.
Common Use Cases
Section titled “Common Use Cases”On-demand research: Add a topic string input and trigger with gh aw run research --raw-field topic="AI safety" when needed.
Manual operations: Use a choice input with predefined operations (cleanup, sync, audit) to execute specific tasks on demand.
Testing and debugging: Add workflow_dispatch to event-triggered workflows (issues, PRs) with optional test URL inputs to test without creating real events.
Scheduled workflow testing: Combine schedule with workflow_dispatch to test scheduled workflows immediately rather than waiting for the cron schedule.
Troubleshooting
Section titled “Troubleshooting”Workflow not listed in GitHub UI: Verify workflow_dispatch: exists in the on: section, compile the workflow (gh aw compile workflow), and push both .md and .lock.yml files. The Actions page may need a refresh.
“Workflow not found” error: Use the filename without .md extension (research not research.md). Ensure the workflow exists in .github/workflows/ and has been compiled.
“Workflow cannot be run” error: Add workflow_dispatch: to the on: section, recompile, and verify the .lock.yml includes the trigger before pushing.
Permission denied: Verify write access to the repository and check the roles: field in workflow frontmatter. For organization repos, confirm your org role.
Inputs not appearing: Check YAML syntax and indentation (2 spaces) in workflow_dispatch.inputs. Ensure input types are valid (string, boolean, choice, environment), then recompile and push.
Wrong branch context: Specify the branch explicitly with --ref branch-name in CLI or select the correct branch in the GitHub UI dropdown before running.
Best Practices
Section titled “Best Practices”Input Design
Section titled “Input Design”Use descriptive input names (analysis_depth not depth) and provide helpful descriptions to guide users. Set sensible defaults for optional inputs and use choice type to constrain options. Avoid creating more than 5 inputs as this becomes overwhelming. Keep truly required inputs minimal—if a default works, make it optional.
Development and Testing
Section titled “Development and Testing”Include workflow_dispatch: in all workflows during development. Test with trial mode first (gh aw trial workflow.md), then verify in-repo behavior with manual dispatch. Clean up test branches after merging and remove debugging inputs before production deployment.
Security
Section titled “Security”Use roles: to restrict sensitive operations and manual-approval: for production workflows. Validate and sanitize all string inputs in workflow logic. Never pass secrets or credentials via inputs—trust input values only after validation. Document who should run which workflows and review run history regularly.
Combining Triggers
Section titled “Combining Triggers”Add workflow_dispatch to event-triggered workflows for testing without creating real issues or PRs. This enables automated execution on real events while allowing manual testing and debugging with specific examples.
Related Documentation
Section titled “Related Documentation”- Manual Workflows Example - Example manual workflows
- Triggers Reference - Complete trigger syntax including workflow_dispatch
- TrialOps Guide - Testing workflows in isolation
- CLI Commands - Complete gh aw run command reference
- Templating - Using expressions and conditionals
- Security Best Practices - Securing workflow execution
- Quick Start - Getting started with agentic workflows