You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: workshop/16-connect-data-source.md
+15-18Lines changed: 15 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,14 +16,12 @@ You'll extend your daily-status workflow to fetch open issues from your reposito
16
16
17
17
### Understand the data-flow pattern
18
18
19
-
[gh-aw workflows](https://github.github.com/gh-aw/introduction/overview/) run inside GitHub Actions, so you can run any shell command — including `gh`. The pattern has three parts:
19
+
[gh-aw workflows](https://github.github.com/gh-aw/introduction/overview/) run inside GitHub Actions, so your workflow can fetch live repository data before the AI writes anything. In this step, you will use shell steps to collect data and a later prompt section to turn that data into a summary.
20
20
21
-
1. A shell step fetches data and writes it to `$GITHUB_OUTPUT`.
22
-
2. A step ID (e.g., `id: recent`) names the step.
23
-
3. The prompt references the output with `${{ steps.<id>.outputs.<key> }}`.
21
+
Think of it as a handoff. First, the workflow gathers facts in a predictable way. Then, the prompt reads those saved results and asks the AI to explain what matters.
24
22
25
23
> [!TIP]
26
-
> If you're unfamiliar with `$GITHUB_OUTPUT`, read [Side Quest: Passing Data Between Steps with $GITHUB_OUTPUT](side-quest-16-01-github-output.md). If you're deciding which parts should be fixed scripts versus AI reasoning, read[Side Quest: Deterministic vs Agentic Data Ops](side-quest-16-04-deterministic-vs-agentic-data-ops.md).
24
+
> If step outputs, here-document syntax, or the scripted versus agentic split are new to you, skim [Side Quest: Passing Data Between Steps with $GITHUB_OUTPUT](side-quest-16-01-github-output.md) and[Side Quest: Deterministic vs Agentic Data Ops](side-quest-16-04-deterministic-vs-agentic-data-ops.md).
27
25
28
26
### Fetch commit history
29
27
@@ -43,7 +41,7 @@ First, fetch the recent commit log:
43
41
echo "EOF" >> $GITHUB_OUTPUT
44
42
```
45
43
46
-
🤔 **Predict:** What will `${{ steps.recent.outputs.commit_log }}` contain if no commits were made in the last 24 hours? Form your prediction now and verify it after you trigger a run.
44
+
🤔 Pause and predict: What will the `commit_log` output contain if no commits were made in the last 24 hours? Form your prediction now and verify it after you trigger a run.
47
45
48
46
### Fetch open issues
49
47
@@ -67,13 +65,13 @@ Next, add a step to fetch open issues:
✏️ **Try it:** Run `gh issue list --state open --json number --jq 'length'` in your terminal and note the count. After you trigger a workflow run, check whether `open_issues_count` matches.
68
+
✏️ Try it: Run `gh issue list --state open --json number --jq 'length'` in your terminal and note the count. After you trigger a workflow run, check whether the workflow reports the same total.
71
69
72
-
🤔 **Predict:** What will the AI receive if `open_issues` is empty (no open issues in the repo)? Will the prompt still produce a useful output?
70
+
🤔 Pause and predict:What will the AI receive if the issue list is empty? Will the prompt still produce a useful output?
73
71
74
72
### Inject data into your AI prompt
75
73
76
-
The AI prompt is the **Markdown body** after the closing `---` of the frontmatter — update it to reference the step outputs:
74
+
The AI prompt lives in the Markdown body after the frontmatter. Update that section so it uses the step outputs:
77
75
78
76
```markdown
79
77
---
@@ -92,11 +90,11 @@ Write a concise, friendly update — two short paragraphs.
92
90
Highlight anything that looks urgent in the issue list.
93
91
```
94
92
95
-
`${{ steps.<id>.outputs.<key> }}`expressions are resolved at runtime before the AI sees the prompt.
93
+
GitHub resolves the step-output expressions before the AI sees the prompt, so the model receives plain text instead of workflow syntax.
96
94
97
-
🤔 **Predict:** If `commit_log` is empty, does the prompt still make sense to the AI? What one-line change would make the instruction more robust?
95
+
🤔 Pause and predict:If the `commit_log` output is empty, does the prompt still make sense to the AI? What one-line change would make the instruction more robust?
98
96
99
-
✏️ **Try it:** Change `"two short paragraphs"` to `"one bullet list per topic"` and re-run. Notice how the output format shifts.
97
+
✏️ Try it: Change `"two short paragraphs"` to `"one bullet list per topic"` and re-run. Notice how the output format shifts.
100
98
101
99
### Compile and test
102
100
@@ -132,14 +130,13 @@ Once you're comfortable with this pattern, the same technique works for:
132
130
133
131
## ✅ Checkpoint
134
132
135
-
- [ ] Your workflow has a `fetch recentcommits` step with `id: recent`
136
-
- [ ] Your workflow has a `fetch openissues` step with `id: issues`
137
-
- [ ] Your AI prompt references `steps.recent.outputs.commit_log` and `steps.issues.outputs.open_issues`
133
+
- [ ] Your workflow has a recent-commits step with `id: recent`
134
+
- [ ] Your workflow has an open-issues step with `id: issues`
135
+
- [ ] Your AI prompt uses both saved outputs
138
136
- [ ] `gh aw compile` reports no errors
139
137
- [ ] A manual run completes and the summary mentions both commits and open issues
140
-
- [ ] You can explain the `<<EOF` multi-line output syntax in your own words
141
-
- [ ] You can explain why `export` doesn't pass data between steps and `$GITHUB_OUTPUT` does
142
-
- [ ] You can describe what happens if `commit_log` is empty and how your prompt handles it
138
+
- [ ] You can explain how the workflow passes fetched data into the prompt
139
+
- [ ] You can describe what happens if the recent commit output is empty and how your prompt handles it
143
140
144
141
**Next:** [Give Your Agent More Tools with MCP](17-add-mcp-tools.md)
0 commit comments