Skip to content

Commit 2afe532

Browse files
[workshop] Add node: Schedule It to Run Every Day (#69)
1 parent 103920d commit 2afe532

2 files changed

Lines changed: 93 additions & 1 deletion

File tree

‎workshop/13-schedule-it.md‎

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Schedule It to Run Every Day
2+
3+
> _Automating the trigger is what turns a one-off script into a true workflow — after this step your report will arrive without you lifting a finger._
4+
5+
## 🎯 What You'll Do
6+
7+
You'll update the `schedule` trigger in your workflow using gh-aw's fuzzy schedule syntax so GitHub Actions runs it at exactly the cadence you want. By the end, you'll know how to express any recurring schedule in plain English.
8+
9+
## 📋 Before You Start
10+
11+
- You have a working, manually tested workflow from [Test and Improve Your Workflow](12-test-and-iterate.md).
12+
- Your workflow file lives at `.github/workflows/daily-status.md`.
13+
14+
## Steps
15+
16+
### 1. Open your workflow file
17+
18+
In your editor (or Codespace), open `.github/workflows/daily-status.md`.
19+
20+
### 2. Locate the `on:` block
21+
22+
You should already have a `schedule: daily` trigger and a `workflow_dispatch` trigger:
23+
24+
```yaml
25+
on:
26+
schedule: daily
27+
workflow_dispatch: {}
28+
```
29+
30+
### 3. Choose your schedule
31+
32+
gh-aw accepts natural-language schedule expressions — no cron syntax needed. The `gh aw compile` command expands them into the correct cron expression automatically.
33+
34+
| What you want | Fuzzy expression |
35+
|---------------|-----------------|
36+
| Once a day (midnight UTC) | `schedule: daily` |
37+
| Weekdays only | `schedule: daily on weekdays` |
38+
| Once a week | `schedule: weekly` |
39+
| Every hour | `schedule: hourly` |
40+
| Every six hours | `schedule: every 6 hours` |
41+
42+
Pick the cadence that fits your team and update the `schedule:` line accordingly. For example, to run only on weekdays:
43+
44+
```yaml
45+
on:
46+
schedule: daily on weekdays
47+
workflow_dispatch: {}
48+
```
49+
50+
> [!TIP]
51+
> Keep `workflow_dispatch` in the file even after you go to production. It lets you re-run the report on demand without changing the schedule.
52+
53+
### 4. Compile and validate
54+
55+
After editing, compile the file to make sure the expression is recognised:
56+
57+
```bash
58+
gh aw compile .github/workflows/daily-status.md --validate
59+
```
60+
61+
You should see `✅ Compiled successfully`. The compiled `.yml` will contain the expanded cron expression — you don't need to write or maintain it by hand.
62+
63+
### 5. Commit and push
64+
65+
```bash
66+
git add .github/workflows/daily-status.md
67+
git commit -m "chore: schedule daily status workflow"
68+
git push
69+
```
70+
71+
### 6. Confirm the schedule is registered
72+
73+
Navigate to your repository on GitHub, then **Actions → daily-status**. On the right-hand sidebar you'll see a **This workflow has a schedule trigger** badge.
74+
75+
![Scheduled workflow badge visible in the Actions sidebar](images/13-schedule-badge.png)
76+
77+
> [!WARNING]
78+
> GitHub may delay the very first scheduled run by up to 15 minutes after you push. If the workflow doesn't fire at the expected time, check **Actions** for queued runs before assuming something is broken.
79+
80+
### 7. Wait for or trigger a run
81+
82+
You can wait for the next scheduled time, or click **Run workflow** → **Run workflow** to trigger it immediately and confirm everything still works.
83+
84+
## ✅ Checkpoint
85+
86+
- [ ] Your `on:` block contains both `workflow_dispatch` and a `schedule` fuzzy expression
87+
- [ ] The schedule expression reflects the cadence you actually want
88+
- [ ] `gh aw compile .github/workflows/daily-status.md --validate` reports no errors
89+
- [ ] You have pushed the change and can see the schedule badge in the Actions UI
90+
- [ ] At least one scheduled (or manual) run has completed successfully after the change
91+
92+
**Next:** [What's Next? Keep Exploring](14-next-steps.md)

‎workshop/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ A hands-on workshop that takes you from zero to a fully automated, AI-powered da
2020
| 10 | [10-design-daily-status.md](10-design-daily-status.md) | Design: Your Daily Repo Status Report | ✅ |
2121
| 11 | [11-build-daily-status.md](11-build-daily-status.md) | Build: Daily Repo Status Workflow | ⏳ |
2222
| 12 | [12-test-and-iterate.md](12-test-and-iterate.md) | Test and Improve Your Workflow | ✅ |
23-
| 13 | [13-schedule-it.md](13-schedule-it.md) | Schedule It to Run Every Day | ⏳ |
23+
| 13 | [13-schedule-it.md](13-schedule-it.md) | Schedule It to Run Every Day | ✅ |
2424
| 14 | [14-next-steps.md](14-next-steps.md) | What's Next? Keep Exploring | ⏳ |
2525

2626
## Getting Started

0 commit comments

Comments
 (0)