diff --git a/workshop/15-conditional-logic.md b/workshop/15-conditional-logic.md index ac4da24c..3b89672b 100644 --- a/workshop/15-conditional-logic.md +++ b/workshop/15-conditional-logic.md @@ -24,6 +24,12 @@ The approach breaks into three parts: 2. Reference that output using the `steps` context expression `${{ steps.recent.outputs.commit_count }}`. 3. Add a top-level `if:` key in the workflow [frontmatter](https://github.github.com/gh-aw/reference/frontmatter/) that skips the agent job when the count evaluates to zero. + + + + Conditional logic flow: shell step writes commit count to GITHUB_OUTPUT, the if condition evaluates it, then either skips or runs the agent job + + ### Add a commit-count step Open your daily-status workflow file (e.g., `.github/workflows/daily-status.md`) and add the following block inside the YAML frontmatter under `steps:`: diff --git a/workshop/images/15-conditional-flow-dark.svg b/workshop/images/15-conditional-flow-dark.svg new file mode 100644 index 00000000..d65a8f60 --- /dev/null +++ b/workshop/images/15-conditional-flow-dark.svg @@ -0,0 +1,84 @@ + + + + + + + Conditional Logic Flow + How a deterministic shell step gates the agentic job + + + + + + Shell Step + git log --since="24h" + | wc -l + id: recent + + + + + + + + + $GITHUB_OUTPUT + commit_count=3 + steps.recent.outputs.commit_count + + + + + + + if: condition + count != '0' + + + + true + + + + + + ✅ Agent Job Runs + AI processes commits + and posts report + + + + false + + + + + + ⏭ Agent Job Skipped + No commits — no report + saved AI tokens + + + + 1 + + 2 + + 3 + + + Gather context + Expose as output + Evaluate condition + + + Deterministic steps run first; the agent job is gated by the evaluated output value. + + + + + + + + diff --git a/workshop/images/15-conditional-flow-light.svg b/workshop/images/15-conditional-flow-light.svg new file mode 100644 index 00000000..77accb05 --- /dev/null +++ b/workshop/images/15-conditional-flow-light.svg @@ -0,0 +1,84 @@ + + + + + + + Conditional Logic Flow + How a deterministic shell step gates the agentic job + + + + + + Shell Step + git log --since="24h" + | wc -l + id: recent + + + + + + + + + $GITHUB_OUTPUT + commit_count=3 + steps.recent.outputs.commit_count + + + + + + + if: condition + count != '0' + + + + true + + + + + + ✅ Agent Job Runs + AI processes commits + and posts report + + + + false + + + + + + ⏭ Agent Job Skipped + No commits — no report + saved AI tokens + + + + 1 + + 2 + + 3 + + + Gather context + Expose as output + Evaluate condition + + + Deterministic steps run first; the agent job is gated by the evaluated output value. + + + + + + + +