How to Manually Trigger a Workflow With Inputs in GitHub Actions
workflow_dispatch adds a Run workflow button; inputs let operators choose parameters at launch.
Declare on.workflow_dispatch.inputs with types and defaults, then reference ${{ inputs.<name> }} (or github.event.inputs.<name>) in jobs.
Steps
- Add
workflow_dispatchunderonwith aninputs:map. - Give each input a
type(string, boolean, choice, environment) anddefault. - Read values via
${{ inputs.<name> }}in steps.
Workflow
.github/workflows/deploy.yml
on:
workflow_dispatch:
inputs:
environment:
type: choice
options: [staging, production]
default: staging
dry_run:
type: boolean
default: true
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- run: ./deploy.sh --env ${{ inputs.environment }} --dry-run ${{ inputs.dry_run }}Gotchas
- The workflow file must exist on the default branch before the button appears.
- All input values arrive as strings; compare booleans as
== 'true'.
Related guides
How to Schedule a Nightly Build in GitHub ActionsRun a nightly GitHub Actions build with on.schedule and a cron expression, useful for regression suites, depe…
How to Reuse a Workflow With workflow_call in GitHub ActionsBuild a reusable GitHub Actions workflow with on.workflow_call, declaring inputs and secrets, then call it fr…