From 3efdf5383f904184ba6a7ec236a3a6f176f22f20 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 09:15:33 +0000 Subject: [PATCH 1/4] Initial plan From a3b4cf0efec27a9262ff11bd1665d3bacb8752f0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 09:25:14 +0000 Subject: [PATCH 2/4] improve(workshop): fix readability, callout density, and add exercises in step 15 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Reduce callout blocks from 4 to 3 (convert TIP to inline prose) - Rewrite short sentences into fuller technical prose (target FK 8-10) - Add hands-on Exercise: weekend skip condition with step-by-step instructions - Expand side-quest-15-01 with 'Combine multiple conditions' and 'Gather time-based context' sections covering && / || patterns and the date +%A shell technique — absorbing the 5 excess concepts from the main step - Update side-quest checkpoint with two new items Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- workshop/15-conditional-logic.md | 58 ++++++++++++------- ...de-quest-15-01-expressions-and-contexts.md | 37 ++++++++++++ 2 files changed, 73 insertions(+), 22 deletions(-) diff --git a/workshop/15-conditional-logic.md b/workshop/15-conditional-logic.md index 1d2cfb6d..3038a86e 100644 --- a/workshop/15-conditional-logic.md +++ b/workshop/15-conditional-logic.md @@ -6,7 +6,7 @@ ## 🎯 What You'll Do -Add a conditional check to your daily-status workflow so it only posts a summary when there have been recent commits. You'll learn how to use shell commands to gather context and pass that context into your AI prompt. +Add a conditional check to your daily-status workflow so it only posts a summary when there have been recent commits. You'll learn how to use shell commands to gather context, expose that context as step outputs, and wire it into an `if:` condition that short-circuits the agent job entirely on quiet days. ## 📋 Before You Start @@ -17,16 +17,16 @@ Add a conditional check to your daily-status workflow so it only posts a summary ### Understand the problem -Right now your daily-status workflow runs every weekday — even on days when nothing happened. That means noisy, unhelpful summaries like "No activity to report." Conditional logic lets you skip the AI call entirely on quiet days. +Your daily-status workflow currently runs every weekday regardless of repository activity, which means it can produce empty or near-empty summaries like "No activity to report" on quiet days. Over time these hollow reports erode confidence in the tool because readers learn to ignore them. Conditional logic solves this by inspecting repository state in a deterministic shell step before any AI processing begins, then skipping the agent job entirely when the precondition is not met. -The approach: -1. Run a shell command to count recent commits. -2. Store the result in an output variable. -3. Add a top-level `if:` in workflow [frontmatter](https://github.github.com/gh-aw/reference/frontmatter/) to skip the agent job when the count is zero. +The approach breaks into three parts: +1. Run a shell command to count commits from the last 24 hours and write the result to `$GITHUB_OUTPUT`. +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. ### Add a commit-count step -Open your daily-status workflow file (e.g., `.github/workflows/daily-status.md`) and add this inside the YAML frontmatter under `steps:`: +Open your daily-status workflow file (e.g., `.github/workflows/daily-status.md`) and add the following block inside the YAML frontmatter under `steps:`: ```yaml steps: @@ -37,38 +37,52 @@ steps: echo "commit_count=$COUNT" >> $GITHUB_OUTPUT ``` -This shell command: -- Uses `git log` with a time filter to list commits from the last 24 hours. -- Counts the lines with `wc -l`. -- Writes the result to `$GITHUB_OUTPUT` so the next step can read it. +This shell command uses `git log` with a `--since` time filter to list only commits from the last 24 hours, pipes the output through `wc -l` to count the lines, strips surrounding whitespace with `tr -d ' '`, and writes the final integer to `$GITHUB_OUTPUT` — a special GitHub Actions file that shares values between steps using `key=value` notation. The `id: recent` field is essential: it creates a named slot in the `steps` context so the value can be referenced as `steps.recent.outputs.commit_count` in later steps or in the top-level `if:` condition. > [!NOTE] >
-> `$GITHUB_OUTPUT` is a special GitHub Actions file. Anything you write in the format `key=value` becomes available to later steps as `steps..outputs.key`. +> `$GITHUB_OUTPUT` makes step outputs available to later steps as `steps..outputs.key`. > -> Want to understand how `${{ steps.recent.outputs.commit_count }}` works and what other context objects exist? See [Side Quest: GitHub Actions Expressions and Contexts](side-quest-15-01-expressions-and-contexts.md). +> For a deeper explanation of how the `steps` context works alongside other context objects (`github`, `env`, `runner`), how to use built-in expression functions like `contains()` and `toJSON()`, and how to chain conditions with `&&` and `||`, see [Side Quest: GitHub Actions Expressions and Contexts](side-quest-15-01-expressions-and-contexts.md). > >
### Add a top-level condition in frontmatter -In the same frontmatter block, add a top-level `if:` key (at the same level as `on:` and `steps:`): +In the same frontmatter block, add a top-level `if:` key at the same indentation level as `on:` and `steps:`: ```yaml if: steps.recent.outputs.commit_count != '0' ``` -This condition skips the compiler-generated agent job entirely when `commit_count` is `0`. +This condition is evaluated during [compilation](https://github.github.com/gh-aw/reference/compilation-process/) and embedded into the generated lock file, causing the agent job to be skipped entirely whenever `commit_count` evaluates to `'0'`. You can also reference the count inside your prompt text to give the model concrete context — for example: `"Summarise the last ${{ steps.recent.outputs.commit_count }} commits"` anchors the analysis to the actual number of changes rather than leaving the model to guess the scope. -> [!TIP] -> You can use `${{ steps.recent.outputs.commit_count }}` inside your prompt text too — for example: "Summarise the last ${{ steps.recent.outputs.commit_count }} commits." +### Exercise: Add a weekend skip condition -### Test it locally first +Now that the commit-count condition is in place, extend the workflow to also skip execution on weekends. This exercise reinforces how to chain multiple conditions in a single `if:` expression. + +1. Add a step that writes the current day name as an output: + +```yaml +- name: Check day of week + id: day + run: echo "day=$(date +%A)" >> $GITHUB_OUTPUT +``` + +1. Update the top-level `if:` to combine both conditions using `&&`: + +```yaml +if: steps.recent.outputs.commit_count != '0' && steps.day.outputs.day != 'Saturday' && steps.day.outputs.day != 'Sunday' +``` + +1. Compile the workflow with `gh aw compile`, trigger a manual `workflow_dispatch` run from the Actions tab, and check the run log. On a weekday with commits, the agent job should complete normally; on a weekend or a day with no commits, it should appear as **skipped** with a grey icon. + +### Test your condition Use `workflow_dispatch` to trigger the workflow manually. Check the run log: -- If there were recent commits, the summary should run. -- If not, you should see the agent job marked as **skipped** (a grey icon in the Actions UI). +- If there were recent commits (and it is a weekday), the summary should run and the agent job will display a green checkmark. +- If the commit count is zero or the run is on a weekend, the agent job will be marked as **skipped** (a grey icon in the Actions UI). ![Skipped step in GitHub Actions](images/15-skipped-step.svg) @@ -80,10 +94,10 @@ After editing the frontmatter, compile the workflow to confirm everything is val gh aw compile ``` -You should see `✅ Compiled successfully`. This regenerates your `.lock.yml` file with the updated conditional logic. +You should see `✅ Compiled successfully`. This regenerates your `.lock.yml` file with the updated conditional logic embedded in the job definition. > [!NOTE] -> The `if:` condition is applied during [compilation](https://github.github.com/gh-aw/reference/compilation-process/) — it won't take effect until you compile and push both files. +> The `if:` condition is applied during [compilation](https://github.github.com/gh-aw/reference/compilation-process/) and will not take effect until you compile and push both the `.md` source and the updated `.lock.yml` file. ### Commit and push your conditional logic diff --git a/workshop/side-quest-15-01-expressions-and-contexts.md b/workshop/side-quest-15-01-expressions-and-contexts.md index aa9f77fc..86d6414f 100644 --- a/workshop/side-quest-15-01-expressions-and-contexts.md +++ b/workshop/side-quest-15-01-expressions-and-contexts.md @@ -119,12 +119,49 @@ if: contains(github.event.head_commit.message, '[skip ci]') > [!NOTE] > Expressions are evaluated on the GitHub Actions runner, not inside the AI agent. Use them for workflow control flow, not for shaping the AI prompt at runtime — pass values to the prompt via environment variables in your brief instead. +### Combine multiple conditions + +The `&&` (AND) and `||` (OR) operators let you build composite conditions that express more nuanced rules than a single comparison allows. When combining multiple shell-derived outputs, keep in mind that all values written to `$GITHUB_OUTPUT` arrive as strings, so always compare them against quoted literals. + +```yaml +# Run only when there are commits AND the branch is main +if: steps.recent.outputs.commit_count != '0' && github.ref == 'refs/heads/main' + +# Run when triggered manually OR there are recent commits +if: github.event_name == 'workflow_dispatch' || steps.recent.outputs.commit_count != '0' + +# Skip weekends by combining day-of-week outputs from a shell step +if: steps.day.outputs.day != 'Saturday' && steps.day.outputs.day != 'Sunday' +``` + +### Gather time-based context with shell steps + +Some conditions require information that is not available in any context object — for example, the current day of the week or the number of commits since a given timestamp. You can capture this data in a dedicated shell step and then reference it like any other output. + +A step that exposes the current day name: + +```yaml +- name: Check day of week + id: day + run: echo "day=$(date +%A)" >> $GITHUB_OUTPUT +``` + +Once this step runs, `steps.day.outputs.day` holds a value like `Monday` or `Saturday`. Combine it with a commit-count check to build a condition that skips the agent job on both quiet days and weekends: + +```yaml +if: steps.recent.outputs.commit_count != '0' && steps.day.outputs.day != 'Saturday' && steps.day.outputs.day != 'Sunday' +``` + +This pattern — deterministic shell step produces a string output, `if:` expression reads that output — applies broadly wherever you need workflow control flow based on data that is not already in a GitHub Actions context object. + ## ✅ Checkpoint - [ ] You can explain what `${{ }}` does and when GitHub evaluates it - [ ] You can name at least three context objects and what they contain - [ ] You understand how `id:` connects a step's output to the `steps` context - [ ] You can write an `if:` condition that skips a step based on a previous output +- [ ] You can combine two or more conditions using `&&` and `||` +- [ ] You can write a shell step that captures time-based data (day of week, date) as a step output **Next:** [Connect a Live Data Source to Your Workflow](16-connect-data-source.md) From e8d6ff13bccf896137ca79ed291cc57d45146113 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 09:26:22 +0000 Subject: [PATCH 3/4] refactor(workshop): clarify exercise steps and remove duplicate test section in step 15 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per code review: split exercise step 3 into three distinct action items (compile, trigger, inspect) and remove the now-redundant 'Test your condition' section — its skipped-step image is preserved inline. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- workshop/15-conditional-logic.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/workshop/15-conditional-logic.md b/workshop/15-conditional-logic.md index 3038a86e..fcde46b7 100644 --- a/workshop/15-conditional-logic.md +++ b/workshop/15-conditional-logic.md @@ -75,14 +75,11 @@ Now that the commit-count condition is in place, extend the workflow to also ski if: steps.recent.outputs.commit_count != '0' && steps.day.outputs.day != 'Saturday' && steps.day.outputs.day != 'Sunday' ``` -1. Compile the workflow with `gh aw compile`, trigger a manual `workflow_dispatch` run from the Actions tab, and check the run log. On a weekday with commits, the agent job should complete normally; on a weekend or a day with no commits, it should appear as **skipped** with a grey icon. +1. Compile the workflow with `gh aw compile` to regenerate the lock file with the combined condition. -### Test your condition +1. Trigger a manual `workflow_dispatch` run from the Actions tab. -Use `workflow_dispatch` to trigger the workflow manually. Check the run log: - -- If there were recent commits (and it is a weekday), the summary should run and the agent job will display a green checkmark. -- If the commit count is zero or the run is on a weekend, the agent job will be marked as **skipped** (a grey icon in the Actions UI). +1. Inspect the run log: on a weekday with commits the agent job should complete normally; on a weekend or a day with no commits it should appear as **skipped** with a grey icon, as shown below. ![Skipped step in GitHub Actions](images/15-skipped-step.svg) From aaff7c29aa75803e1dfb0c04a628284a2af5707d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 09:43:10 +0000 Subject: [PATCH 4/4] fix(workshop): correct if: evaluation timing in step 15 Compilation only embeds the expression verbatim into the lock file; GitHub Actions evaluates it at runtime when the step output exists. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- workshop/15-conditional-logic.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workshop/15-conditional-logic.md b/workshop/15-conditional-logic.md index fcde46b7..bf393467 100644 --- a/workshop/15-conditional-logic.md +++ b/workshop/15-conditional-logic.md @@ -55,7 +55,7 @@ In the same frontmatter block, add a top-level `if:` key at the same indentation if: steps.recent.outputs.commit_count != '0' ``` -This condition is evaluated during [compilation](https://github.github.com/gh-aw/reference/compilation-process/) and embedded into the generated lock file, causing the agent job to be skipped entirely whenever `commit_count` evaluates to `'0'`. You can also reference the count inside your prompt text to give the model concrete context — for example: `"Summarise the last ${{ steps.recent.outputs.commit_count }} commits"` anchors the analysis to the actual number of changes rather than leaving the model to guess the scope. +This condition is embedded into the generated lock file during [compilation](https://github.github.com/gh-aw/reference/compilation-process/); at runtime, GitHub Actions evaluates it and skips the agent job entirely whenever `commit_count` evaluates to `'0'`. You can also reference the count inside your prompt text to give the model concrete context — for example: `"Summarise the last ${{ steps.recent.outputs.commit_count }} commits"` anchors the analysis to the actual number of changes rather than leaving the model to guess the scope. ### Exercise: Add a weekend skip condition