How do you trigger a `workflow_dispatch` from the CLI and from the API?
BeginnerConceptTriggers & Events
Answer
gh workflow run deploy.yml --ref main -f environment=staging -f dry_run=false
gh run watch $(gh run list --workflow deploy.yml --limit 1 --json databaseId -q '.[0].databaseId')
API:
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Accept: application/vnd.github+json" \
https://api.github.com/repos/ORG/REPO/actions/workflows/deploy.yml/dispatches \
-d '{"ref":"main","inputs":{"environment":"staging"}}'
The workflow must exist on the default branch for the button and the gh workflow run lookup to appear.
More on Triggers & Events
How do you trigger a workflow on pushes to `main` and on PRs that target `main`?BeginnerWhat activity types does `pull_request` trigger on by default, and how do you add more?IntermediateHow do `branches` and `branches-ignore` filters work with globs?BeginnerHow do path filters work, and what are their limits?AdvancedHow do you trigger only on version tags, and what is the gotcha with pushing many tags?IntermediateWhat is `workflow_dispatch`, and what input types does it support?Beginner