Skip to content

Commit 65021db

Browse files
authored
Improve frontmatter deep-dive: add hands-on exercises, reduce concept catalog, add mini-challenge (#1783)
1 parent 0b6ec30 commit 65021db

1 file changed

Lines changed: 133 additions & 25 deletions

File tree

workshop/side-quest-11-01-frontmatter-deep-dive.md

Lines changed: 133 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
<!-- page-adventure: side-quest -->
33
# Side Quest: Frontmatter Deep Dive — Part A
44

5-
> _Optional: a section-by-section walkthrough of the opening three frontmatter sections in a `gh-aw` workflow file. Work through this before building Step 11, then continue to [Part B: Tools, Outputs, and the Agent Body](side-quest-11-08-frontmatter-tools-outputs.md) or return to the main path._
5+
> _Optional: configure each of the opening three frontmatter sections of an agentic workflow file — metadata, triggers, and permissions. Work through this before building Step 11, then continue to [Part B: Tools, Outputs, and the Agent Body](side-quest-11-08-frontmatter-tools-outputs.md) or return to the main path._
66
77
## 📋 Before You Start
88

9-
You have read [Step 11](07-your-first-workflow.md) and have a draft frontmatter file open.
9+
Open the draft workflow file you started in [Step 11](07-your-first-workflow.md).
1010

1111
---
1212

13-
An agentic workflow file opens with a YAML **[frontmatter](https://github.github.com/gh-aw/reference/frontmatter/)** block between `---` fences. This block configures when the workflow runs and what it is allowed to do. This page covers the first three sections: metadata, triggers, and permissions.
13+
An agentic workflow file opens with a YAML **[frontmatter](https://github.github.com/gh-aw/reference/frontmatter/)** block between `---` separators. This block configures when the workflow runs and what it is allowed to do.
1414

1515
---
1616

@@ -24,17 +24,22 @@ emoji: 📊
2424
description: Post a daily repository status summary as a GitHub issue comment.
2525
```
2626
27-
**What this section does:** Opens the YAML frontmatter and declares human-readable metadata.
27+
**What this section does:** Declares the workflow's metadata.
2828
2929
| Field | Purpose |
3030
|-------|---------|
31-
| `---` | Signals the start of YAML frontmatter. Everything until the next `---` is structured configuration. |
32-
| `emoji` | A decorative label shown in the `gh aw` dashboard. Pick any emoji that fits. |
33-
| `description` | A one-sentence summary shown in the GitHub Actions UI and in `gh aw list`. |
31+
| `emoji` | Decorative label in the `gh aw` dashboard. Pick any emoji that fits. |
32+
| `description` | Summary shown in the Actions UI and in `gh aw list`. |
3433

35-
**✏️ Try it:** Update `emoji` and `description` in your draft file to match your workflow.
34+
**✏️ Try it:** Update both fields in your draft, then run `gh aw compile` and confirm no errors appear.
3635

37-
**✅ Check:** Run `gh aw compile` — the output should list your workflow with no errors.
36+
```yaml
37+
# Your turn
38+
---
39+
emoji: ???
40+
description: ???
41+
---
42+
```
3843

3944
---
4045

@@ -48,20 +53,37 @@ on:
4853
workflow_dispatch: {}
4954
```
5055

51-
**What this section does:** Tells GitHub Actions _when_ to run this workflow.
56+
**What this section does:** Declares when the workflow runs.
5257

5358
| Field | Purpose |
5459
|-------|---------|
55-
| `on:` | Declares all triggers. Every GitHub Actions workflow must have this key. |
56-
| `schedule: daily` | Runs once per day at a compiler-assigned time (scattered to avoid load spikes). Also available: `hourly`, `weekly`. |
57-
| `workflow_dispatch: {}` | Adds a **Run workflow** button in the GitHub Actions UI. The `{}` means no custom inputs are required. |
60+
| `on:` | Declares all triggers. |
61+
| `schedule: daily` | Daily run at a compiler-assigned time. See the [triggers reference](https://github.github.com/gh-aw/reference/triggers/) for other intervals. |
62+
| `workflow_dispatch: {}` | Adds a manual trigger button in the Actions UI. |
5863

5964
> [!TIP]
60-
> Keep `workflow_dispatch` even after going to production — it lets you re-run the report on demand without changing the schedule.
65+
> Keep `workflow_dispatch: {}` even after going to production — it lets you re-run the report on demand.
66+
67+
**✏️ Try it:** Add both trigger keys to your draft and run `gh aw compile`. Then extend the block to also fire on pushes to the main branch:
68+
69+
```yaml
70+
on:
71+
schedule: daily
72+
push:
73+
branches: [main]
74+
workflow_dispatch: {}
75+
```
6176

62-
**✏️ Try it:** Add both trigger keys to your draft file and save.
77+
```yaml
78+
# Your turn: configure schedule, push to main, and manual triggers
79+
on:
80+
???: ??? # daily run
81+
push:
82+
branches: [???] # target branch
83+
???: {} # manual trigger
84+
```
6385

64-
**✅ Check:** Run `gh aw compile` — the compile should succeed, and you should see both `schedule` and `workflow_dispatch` listed under triggers.
86+
**✅ Check:** Run `gh aw compile` — the compiled output should list all three triggers.
6587

6688
---
6789

@@ -78,26 +100,112 @@ permissions:
78100
actions: read
79101
```
80102

81-
**What this section does:** Declares exactly which GitHub API scopes this workflow is allowed to use. Minimal permissions are a security best practice.
103+
**What this section does:** Declares the GitHub API scopes this workflow may use — fewer scopes is safer.
82104

83-
The five entries above cover reading repository content, issues, pull requests, and workflow runs, plus the `copilot-requests: write` scope that the Copilot engine requires to authenticate with `${{ github.token }}`. Full definitions for each field are in [Part B: Tools, Outputs, and the Agent Body](side-quest-11-08-frontmatter-tools-outputs.md).
105+
| Field | Purpose |
106+
|-------|---------|
107+
| `permissions:` | Lists every scope the workflow may use; omitted scopes are denied. |
108+
| `contents: read` | Read access to repository files and commits. |
109+
| `copilot-requests: write` | Required by the Copilot engine. |
110+
| `issues: read` | Read access to issue data. |
111+
| `pull-requests: read` | Read access to pull request data. |
112+
| `actions: read` | Read access to workflow run results. |
84113

85-
> [!NOTE]
86-
> There is no `issues: write` here. Write access is handled by `safe-outputs` — covered in [Part B](side-quest-11-08-frontmatter-tools-outputs.md).
114+
**✏️ Try it:** Add the `permissions:` block to your draft. Then fill in the correct permission value for each scope:
87115

88-
**✏️ Try it:** Add the `permissions:` block to your draft. Verify that `copilot-requests: write` is included.
116+
```yaml
117+
# Your turn: fill in the correct value for each scope (read or write)
118+
permissions:
119+
contents: ???
120+
copilot-requests: ???
121+
issues: ???
122+
pull-requests: ???
123+
actions: ???
124+
```
89125

90126
**✅ Check:** Run `gh aw compile` — the compile should complete with no permission errors.
91127

92128
---
93129

130+
## Mini-challenge
131+
132+
Write the `on:` block for schedule + push to main + manual trigger from memory, then validate with `gh aw compile`.
133+
134+
```yaml
135+
# Write the on: block below from memory
136+
on:
137+
```
138+
139+
<details><summary>Solution</summary>
140+
141+
```yaml
142+
on:
143+
schedule: daily
144+
push:
145+
branches: [main]
146+
workflow_dispatch: {}
147+
```
148+
149+
Run `gh aw compile` and verify all three triggers appear.
150+
</details>
151+
152+
Now combine all three sections into one complete frontmatter block and compile it:
153+
154+
```yaml
155+
# Your turn: combine all three sections
156+
---
157+
emoji: ???
158+
description: ???
159+
on:
160+
???: ??? # daily run
161+
push:
162+
branches: [???] # target branch
163+
???: {} # manual trigger
164+
permissions:
165+
contents: ???
166+
copilot-requests: ???
167+
issues: ???
168+
pull-requests: ???
169+
actions: ???
170+
---
171+
```
172+
173+
<details><summary>Solution</summary>
174+
175+
```yaml
176+
---
177+
emoji: 📊
178+
description: Post a daily repository status summary as a GitHub issue comment.
179+
on:
180+
schedule: daily
181+
push:
182+
branches: [main]
183+
workflow_dispatch: {}
184+
permissions:
185+
contents: read
186+
copilot-requests: write
187+
issues: read
188+
pull-requests: read
189+
actions: read
190+
---
191+
```
192+
193+
</details>
194+
195+
---
196+
94197
## ✅ Checkpoint
95198

96199
- [ ] You updated `emoji` and `description` in your draft and `gh aw compile` produced no errors.
97-
- [ ] You added both `schedule: daily` and `workflow_dispatch` triggers, and `gh aw compile` lists both with no errors.
98-
- [ ] The `workflow_dispatch` trigger appears in your Actions UI after pushing the file.
99-
- [ ] You added the `permissions:` block with all five entries and `copilot-requests: write` is present.
100-
- [ ] You can explain why `copilot-requests: write` is required and where to find full field definitions.
200+
- [ ] You added `schedule: daily` and `workflow_dispatch: {}` triggers; both appear in the compiled output.
201+
- [ ] You added a push trigger for the main branch and confirmed it compiles correctly.
202+
- [ ] You can explain why keeping `workflow_dispatch: {}` alongside a schedule trigger is useful.
203+
- [ ] You added the `permissions:` block with all five entries.
204+
- [ ] `copilot-requests: write` is present in your permissions block.
205+
- [ ] You completed the mini-challenge: schedule, push to main, and workflow_dispatch triggers all appear in the compiled output.
206+
- [ ] You can explain what each permission scope in the block allows.
207+
- [ ] You wrote a complete combined frontmatter block and it compiled without errors.
208+
- [ ] The `workflow_dispatch: {}` trigger appears as a manual trigger button in your GitHub Actions UI after pushing.
101209

102210
---
103211

0 commit comments

Comments
 (0)