MSBA-308 · Lesson 3 of 12 · 21 min
Domain review: authoring workflows
▶ Video coming soon A video version of this lesson is on the way.
The first domain review fell on a Monday, and Priya brought a printout of TrailCheck's pipeline.yml, the capstone workflow Lena had built in the Actions clinic. "This file touches about two thirds of the first domain," Priya said. "We'll walk the outline bullet by bullet and point at the line in this file that answers it. Where there is no line, that's what you practice this week." The first domain, Author and manage workflows, carries 20 to 25 of the exam weight. It has three subgroups: triggers and events, workflow structure, and execution and outputs. Authoring and Troubleshooting GitHub Actions Workflows taught all of it; this lesson reviews it the way the exam asks about it.
Triggers and events
The first subgroup asks you to configure workflows for scheduled, manual, webhook and repository events, choose an appropriate scope, permissions and events, and define workflow_dispatch inputs and pass inputs and secrets to reusable workflows. In exam terms, most trigger questions are about choosing the right event for a described need and narrowing it correctly.
| Need in the scenario | Event | Detail the exam likes |
|---|---|---|
| Run checks on every pull request to main | pull_request with branches: [main] | Runs from forks get a read-only token and no secrets |
| Run only when docs change | push or pull_request with paths | paths-ignore is the opposite filter; do not combine both for one event |
| Nightly build | schedule with a cron expression | Shortest interval is five minutes; times are UTC unless a timezone is set beside the cron |
| A button with inputs | workflow_dispatch | Inputs have types such as string, boolean, choice, number and environment |
| Another system triggers the run | repository_dispatch | Sent through the REST API with an event type and an optional payload |
| Called by another workflow | workflow_call | Declares inputs, secrets and outputs |
| React to another workflow finishing | workflow_run | Runs in the context of the default branch |
Manual inputs are named explicitly in the outline: types, required and defaults. A workflow can declare up to 25 inputs for workflow_dispatch. A choice input lists its options; a boolean input arrives as a true or false value; an environment input offers the repository's environments. Inside the workflow, inputs are read through the inputs context. A classic exam distractor is the older github.event.inputs path, which still works for workflow_dispatch but returns every value as a string, so a boolean compared with true can surprise you. The inputs context keeps the declared type.
on:
workflow_dispatch:
inputs:
region:
description: 'Guide region to rebuild'
type: choice
options: [fundy, highlands, all]
default: all
dry_run:
type: boolean
default: true
jobs:
rebuild:
uses: tidewater/.github/.github/workflows/rebuild.yml@v2
with:
region: ${{ inputs.region }}
dry_run: ${{ inputs.dry_run }}
secrets:
TILES_TOKEN: ${{ secrets.TILES_TOKEN }}The second half of that bullet is about reusable workflows. The caller uses jobs.<id>.uses with the path to the workflow and a ref, passes inputs with with, and passes secrets either one by one under secrets or all at once with secrets: inherit. The called workflow must declare each input under on.workflow_call.inputs, with a type. A reusable workflow cannot read the caller's secrets unless they are passed. Since late 2025 reusable workflows can be nested up to ten levels deep, with up to 50 workflows in one run.
Workflow structure
This subgroup is the largest in the outline: jobs, steps and conditions; job dependencies; workflow commands and environment variables; service containers; matrices; YAML anchors; contexts; expressions; and editor tooling. The exam tends to test the relationships between these pieces rather than any one of them alone.
Jobs and dependencies. Jobs run in parallel unless needs says otherwise. A job that needs another skips when its dependency fails, unless its if uses a status function. if: always() runs regardless; if: failure() runs only when something before it failed; if: success() is the default. A job reads its dependencies' outputs through the needs context, and only through it.
Service containers. A job can start containers beside it under services, for a database or a queue the tests need. On a job that runs directly on the runner, you map ports and reach the service on localhost; on a job that itself runs in a container, the service is reachable by its label as a host name. Health check options passed through options let the job wait until the service is ready. Service containers need a Linux runner.
Matrices. strategy.matrix multiplies a job across values. include adds extra combinations or extra keys to existing ones; exclude removes combinations. fail-fast, true by default, cancels remaining matrix jobs when one fails; max-parallel limits how many run at once. A matrix can produce at most 256 jobs per workflow run. The outline asks you to optimize matrix size for cost, which in practice means testing the full grid only where it adds information and using include for the few extra combinations you need.
Worked problem
Reading a matrix with include and exclude
A job has matrix os: [ubuntu-latest, windows-latest] and node: [22, 24], with exclude: [{os: windows-latest, node: 22}] and include: [{os: ubuntu-latest, node: 26, experimental: true}]. How many jobs run, and which has experimental set?
Show solution
- The base grid is 2 x 2 = 4 combinations.
- exclude removes Windows with Node 22, leaving 3.
- include adds Ubuntu with Node 26, which is not in the grid, as a new combination: 4 jobs.
- Only the added combination has the experimental key.
Answer: Four jobs; only ubuntu-latest with Node 26 has experimental: true.
Contexts and expressions. The outline lists the contexts it expects you to know: github, runner, env, vars, secrets, inputs, matrix, needs, strategy, job, steps, and github.event and github.ref within github. It also asks you to distinguish static evaluation, when the workflow is parsed, from runtime evaluation. Some keys are evaluated before a job starts, so only some contexts are available in them. The documentation's context availability table is the reference; the exam pattern to remember is that the secrets context cannot be used directly in an if condition. To branch on whether a secret exists, put it in an environment variable at job level and test the variable.
Expressions use the dollar-brace syntax and support operators, literals and functions such as contains, startsWith, format, join, toJSON and fromJSON, plus the status functions. fromJSON is how a job turns a JSON string output into a matrix, which is the standard way to build a dynamic matrix from an earlier job.
Workflow commands and environment files. Steps talk to the runner by writing to files whose paths are in environment variables: GITHUB_ENV sets variables for later steps, GITHUB_OUTPUT sets step outputs, GITHUB_PATH adds directories to the path, and GITHUB_STEP_SUMMARY adds Markdown to the job summary. Older set-output and set-env commands printed to the log are deprecated. Commands that print to the log, such as ::add-mask::, ::error:: and ::group::, are still current.
Editor tooling. The outline names the GitHub Actions extension for Visual Studio Code and YAML schema validation. The extension lists workflow runs, validates syntax and offers completion for keys and for actions' inputs from their metadata. A question might ask how to catch an invalid key before pushing; the extension or schema validation in the editor is the answer.
YAML anchors. Workflow files support YAML anchors, aliases and merge keys, so a repeated block can be written once. Lesson 8 covers reading them in detail, because they are as much a troubleshooting topic as an authoring one.
Execution and outputs
The last subgroup covers caching and artifacts, passing data, job summaries, status badges and environment protections.
| Tool | Best for | Key behavior |
|---|---|---|
| Cache | Dependencies reused across runs | Restored by key and restore-keys; saved after the job only if there was no exact key match |
| Artifact | Files produced by a run, shared with later jobs or people | Uploaded per run, downloadable in the UI or API, retention default 90 days, configurable |
| Job output | Small values between jobs | Set from a step output, read through needs |
| GITHUB_ENV | Variables for later steps in the same job | Written as name=value lines to the file |
| Job summary | A readable report on the run page | Markdown appended to GITHUB_STEP_SUMMARY |
Retention is named in the outline with REST APIs. Artifact and log retention defaults to 90 days and can be set at the repository, organization or enterprise level within the limits the plan allows. Individual artifacts can set retention-days when uploaded. The REST API can list and delete artifacts and runs and change retention settings, which is how an administrator cleans up storage across many repositories.
Cache behavior has a detail that is easy to forget. The cache is saved in the post-job step only when the restore did not find an exact match for the primary key. If the key includes a hash of the lock file, the cache updates whenever dependencies change and stays the same otherwise. A cache keyed on a constant string never updates after the first run.
Badges and environments. A status badge is an image URL for a workflow, optionally filtered by branch or event, placed in a README. Environment protections are covered again in the security domain: required reviewers, wait timers and deployment branch rules attach to an environment, and a job that references the environment waits for them. On the Team plan these protections are available for public repositories; private repositories need GitHub Enterprise for required reviewers and wait timers, which is why Tidewater's public TrailCheck repository uses them.
Worked problem
Passing a value from one job to another
The build job computes an image tag in a step with id meta. The deploy job needs it. What three pieces are required?
Show solution
- In the step, write tag=<value> to the file named by GITHUB_OUTPUT.
- Declare a job output in build, for example outputs: tag: the step's output read through the steps context with the meta id.
- In deploy, add needs: build and read the value through the needs context, needs.build.outputs.tag.
Answer: A step output written to GITHUB_OUTPUT, a job-level outputs mapping in build, and needs plus the needs context in deploy.
Concurrency and timeouts
Two smaller authoring keys appear in many scenario questions. concurrency puts runs or jobs into a named group so that only one runs at a time; with cancel-in-progress set to true, a new run cancels the one already in the group. A common pattern is a group built from the workflow name and the branch, so a fresh push to a pull request cancels the out-of-date run for that branch without touching other branches. timeout-minutes limits how long a job or step may run. The default for a job is 360 minutes, the same as the six-hour hosted job limit, so a hung test can burn hours of runner time unless a shorter timeout is set. When a question describes wasted minutes from stuck or superseded runs, these two keys are usually the answer.
Job summaries are the last authoring feature worth a line. A step writes Markdown to the file named by GITHUB_STEP_SUMMARY, and the text appears on the run's summary page, which is a tidy way to report test counts or a deployment address without opening the logs.
Lena added one more line to her authoring notes after this review: when a question asks how to stop duplicate runs, think of concurrency; when it asks how to stop runaway runs, think of timeout-minutes; and when it asks how to stop runs that were never needed, think of trigger filters. Three similar problems, three different keys.
Common mistakes
MistakeReading a boolean input through github.event.inputs and comparing it with true.
InsteadUse the inputs context, which keeps the declared type.
MistakeExpecting a reusable workflow to see the caller's secrets automatically.
InsteadPass them one by one or with secrets: inherit.
MistakeTesting a secret directly in an if condition.
InsteadMap it to an environment variable and test the variable.
MistakeAssuming the cache saves at the end of every run.
InsteadIt saves only when there was no exact match on the primary key.
At the end of the session Lena had added four tasks to her week: build a workflow_dispatch form with a choice and a boolean input and pass both into a reusable workflow; run a job with a Postgres service container and a health check; build a dynamic matrix from a JSON output with fromJSON; and watch a cache save, then skip saving on an exact match.
Summary and key terms
- Authoring is 20 to 25 of the exam and covers triggers, structure, and execution and outputs.
- Know which event fits a scenario and how branches, paths, schedules and inputs narrow it.
- Use the inputs context for typed values; pass inputs and secrets to reusable workflows explicitly or with inherit.
- Jobs run in parallel unless needs orders them; outputs flow through needs; status functions change skip behavior.
- Matrices: include adds, exclude removes, fail-fast cancels, max-parallel limits, 256 jobs at most.
- Environment files pass data: GITHUB_ENV, GITHUB_OUTPUT, GITHUB_PATH and GITHUB_STEP_SUMMARY.
- Caches save only without an exact key match; artifact and log retention defaults to 90 days.
- workflow_dispatch
- The event that lets a workflow be run manually, with typed inputs.
- workflow_call
- The event a reusable workflow declares so other workflows can call it.
- Service container
- A container started beside a job for a dependency such as a database.
- Dynamic matrix
- A matrix built at runtime from an earlier job's JSON output using fromJSON.
- Environment file
- A file, such as GITHUB_OUTPUT, that steps write to in order to set values for the runner.
- Status function
- An expression function such as always() or failure() that changes when a step or job runs.
Practice problems
Work each problem on paper first, then reveal the answer to check.
What is the shortest interval a schedule trigger can use?
Show answer
Five minutes.
How does a job read another job's outputs?
Show answer
Through the needs context, after declaring needs on that job.
Which file adds Markdown to the run's summary page?
Show answer
The file named by GITHUB_STEP_SUMMARY.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.