Approvals and Human Input
Some steps should wait for a person: a review before a release, or a choice only a person can make. The run pauses as Waiting and continues when someone responds in the Web UI.
The workflow
bash
curl -fsSLO https://docs.dagu.sh/tutorial/dags/tutorial-09-approvals.yamlyaml
# Dagu tutorial, lesson 9: https://docs.dagu.sh/tutorial/approvals
description: Pause for a review and ask a person for input
type: graph
steps:
- id: build
run: echo "Built release 1.4.0"
approval:
prompt: Check the build output, then approve the release
- id: choose_target
action: human.task
with:
prompt: Where should release 1.4.0 go?
form:
type: object
properties:
environment:
type: string
enum: [staging, production]
required: [environment]
depends: build
- id: deploy
run: echo "Deploying 1.4.0 to ${steps.choose_target.outputs.environment}"
depends: choose_targetapprovalonbuildpauses the run after the step succeeds, until someone approves its output.action: human.taskpauses for a form.formdescribes the fields as a JSON schema. Here,environmentmust be one of two values.${steps.choose_target.outputs.environment}reads the answer. Every form field becomes an output of the task.
Watch it run
deployrunSucceeded
Deploying 1.4.0 to production
The run waits twice: for the approval of build, then for the form. In this recording, a reviewer approved the build and picked production.
Run it yourself
- In the Web UI, open
tutorial-09-approvalsand select Start.buildruns, then the run shows Waiting. - Select Open actions on the canvas, or open Activity → Actions. Review the output of
buildand select Approve. - The form for
choose_targetappears in the same tab. Pick an environment and submit it. deployruns and prints the environment you picked.
A waiting run holds no process or worker slot, so it can wait for as long as the review takes.
Try it
- Start another run and select the reject button in the workflow bar while it waits. How does the run end?
- Add a second form field,
notify, oftype: boolean, and print it indeploy.
Answers
- As Rejected. The steps after the rejected one do not run.
- Add the property to
form, then read it like any other output:
yaml
type: graph
steps:
- id: choose_target
action: human.task
with:
prompt: Where should release 1.4.0 go?
form:
type: object
properties:
environment:
type: string
enum: [staging, production]
notify:
type: boolean
default: true
required: [environment]
- id: deploy
run: echo "Deploying to ${steps.choose_target.outputs.environment}, notify=${steps.choose_target.outputs.notify}"
depends: choose_target
