How to Trigger a Workflow Manually With Inputs in GitHub Actions
workflow_dispatch adds a Run workflow button, and inputs let an operator choose parameters at launch time.
Declare on.workflow_dispatch.inputs with a type and default for each input, then reference inputs.<name> in your jobs.
Steps
- Add
workflow_dispatch:underonwith aninputs:map. - Give each input a
type(string, boolean, choice, environment). - 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 must already exist on the default branch before the Run button appears.
- All inputs arrive as strings; compare booleans as
== 'true'.
Related guides
How to Trigger a Workflow From an External System in GitHub ActionsKick off a GitHub Actions workflow from an outside system with the repository_dispatch event, sending a custo…
How to Trigger a Workflow on a Schedule in GitHub ActionsRun a GitHub Actions workflow on a timetable with on.schedule and a POSIX cron expression in UTC, for nightly…