Trigger Pipelines Manually with workflow_dispatch
workflow_dispatch gives you a 'Run' button in GitHub with custom inputs for on-demand deployments and tasks.
What
The workflow_dispatch trigger lets you run workflows manually from the GitHub UI with custom input parameters. It's perfect for deployments, releases, or one-off maintenance tasks that shouldn't run automatically on every push. You can define typed inputs like dropdowns, booleans, and text fields that appear as a form in the GitHub Actions UI.
Why It Matters
Not everything should be triggered by a git push. Production deployments, database migrations, and cache clears need human judgment on timing. workflow_dispatch gives your team a controlled, auditable way to trigger these operations with configurable parameters β no SSH access or CLI tools required.
Example
# .github/workflows/deploy.yml
name: Manual Deploy
on:
workflow_dispatch:
inputs:
environment:
description: 'Target environment'
required: true
type: choice
options:
- staging
- production
version:
description: 'Version tag to deploy (e.g., v1.2.3)'
required: true
type: string
dry-run:
description: 'Perform a dry run without deploying'
required: false
type: boolean
default: false
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
- name: Deploy
if: ${{ !inputs.dry-run }}
run: |
echo "Deploying ${{ inputs.version }} to ${{ inputs.environment }}"
# ./scripts/deploy.sh ${{ inputs.environment }}
- name: Dry run
if: ${{ inputs.dry-run }}
run: |
echo "DRY RUN: Would deploy ${{ inputs.version }} to ${{ inputs.environment }}"Common Mistake
Not adding input validation. Anyone with write access can trigger the workflow with any input value. A typo in the version tag or selecting the wrong environment can cause a bad deployment. Use choice types for constrained inputs and add validation steps.
Quick Fix
Use type: choice for environment selection instead of free-text strings, add a validation step that checks if the version tag exists before deploying, and use GitHub environment protection rules for production deployments.
Key Takeaways
- 1workflow_dispatch adds a 'Run workflow' button in the GitHub UI
- 2Define typed inputs: choice, string, boolean with defaults
- 3Perfect for manual deployments, releases, and maintenance tasks
- 4Use type: choice to prevent free-text mistakes
- 5Combine with environment protection rules for production safety
Was this tip helpful?
Help us improve the DevOpsPath daily collection