You write your first workflow file, push to main, and open the Actions tab. Empty. No error, no workflow running, nothing. Half an hour later you find it: the folder is .github/workflow/, one letter s short.
GitHub Actions is the CI/CD service built into GitHub, and it has strict rules about where files go and how they are written. You write a workflow (an automated list of steps) in a YAML file in the repo. Every time an event happens (something in the repo, a push for example), GitHub starts a fresh machine and runs the steps. Remember the catering kitchen from the What is CI/CD lesson? A workflow is like the procedure sheet pinned to that kitchen's wall. The sheet says when the work starts (every new order; on GitHub, an event), in which kitchen (a new cook with an empty kitchen; on GitHub, a new machine) and the steps, one by one.
Workflow files live in .github/workflows
GitHub only reads workflows from the .github/workflows/ folder at the repo root (the top folder of the repo). Every .yml or .yaml file in that folder is one workflow. This is notes-api's ci.yml, the same one the Lab uses:
# .github/workflows/ci.yml
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
- run: npm ci
- run: npm test
A little YAML first. Each line holds key: value. Indented lines (with spaces, never tabs) belong to the key above them. A line starting with - is one item of a list, and [main] is a list written on one line.
name: CI: the workflow's name, shown in the Actions tab.on: the events that trigger (start) the workflow.jobs: the list of jobs (a job is a group of steps that run on one machine).testis the job's id (the name it has in the file), and you can pick any id.runs-on: ubuntu-latest: this job runs on a runner, an Ubuntu virtual machine GitHub provides.steps: the job's steps, run in order from the top.
on: when the workflow runs
pushwithbranches: [main]: runs on every commit pushed tomain. A push to another branch triggers nothing.pull_requestwithbranches: [main]: runs when a pull request (PR) intomainis opened, and every time that PR gets a new commit. The branch matched against[main]is the PR's target branch, not the branch it comes from.- Without branch filters it can be shorter:
on: push, or several events at once withon: [push, pull_request]. - Other common events:
workflow_dispatch(a "Run workflow" button to start the workflow by hand) andschedule(runs on a timetable written in cron format, every night for example).
In the exercise, your function reads a simplified format made only for the exercise: on: push, pull_request, with the event names separated by commas. In a real workflow file, a list like that is written with square brackets: on: [push, pull_request].
steps: uses or run
Each step uses one of these two keys:
usesruns an action: ready-made code written by someone else, in the formowner/repo@version.actions/checkout@v7fetches your repo's code, andactions/setup-node@v7installs Node.with:passes inputs to the action, for examplenode-version: 24. Use the latest major version (the first number of the version) from the action's Releases page. The old@v4still runs on Node 20, which reached end of life (no more support) in April 2026.runruns a shell command on the runner, exactly as in a terminal:npm ci,npm test.name:can be added as the step's label in the log. Withoutname, GitHub writes "Run actions/checkout@v7" or "Run npm ci".
If you swap uses and run, each mistake fails in a different way. run: actions/checkout@v7 is run by bash as a command, then fails with actions/checkout@v7: No such file or directory (exit code 127). uses: npm test doesn't even get to run, because GitHub rejects the workflow file: Expected format {org}/{repo}[/path]@ref. Actual 'npm test'.
A runner starts as an empty machine
Every job gets a new, clean machine, and your repo's code isn't there yet. That's why actions/checkout is needed: it copies the repo into the runner's work folder, /home/runner/work/notes-api/notes-api. Without checkout, npm ci can't find package.json:
Run npm ci
npm error code ENOENT
npm error syscall open
npm error path /home/runner/work/notes-api/notes-api/package.json
npm error errno -2
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/home/runner/work/notes-api/notes-api/package.json'
Error: Process completed with exit code 254.
Exit code 254 is not 0, so the step fails. A failed step stops the job: the steps after it are skipped.
Reading an Actions log
Open the Actions tab, pick the run (one time the workflow ran), then pick the test job. For the workflow above, after a push to main, its step list looks like this:
✓ Set up job
✓ Run actions/checkout@v7
✓ Run actions/setup-node@v7
✓ Run npm ci
✓ Run npm test
✓ Post Run actions/setup-node@v7
✓ Post Run actions/checkout@v7
✓ Complete job
- GitHub adds "Set up job" and "Complete job" to prepare and clean up the runner.
- "Post Run ..." is an action's own clean-up step, run at the end in reverse order: setup-node first, then checkout.
- Click a step to open its log. The log of a
runstep starts with its command and the lineshell: /usr/bin/bash -e {0}(bash with-e: it stops at the first command that fails). When a step fails, the last line isError: Process completed with exit code ..., and the reason is just above that line.
Ordering jobs with needs, testing on several Node versions with a matrix, and branch protection (rules that protect main) are covered in the Testing in a CI/CD Pipeline lesson (Testing track). The next lesson, GitHub Actions Advanced, also covers matrices and needs, then continues with caching, environments and secrets.
⚠️ Why doesn't the workflow run, or go red right away?
- The wrong folder. GitHub ignores
.github/workflow/(no s) orgithub/workflows/(no dot) without any message. - Tabs for indentation. YAML only accepts spaces. GitHub rejects the file with
You have an error in your yaml syntax on line .... branch:instead ofbranches:. The key is plural. If you mistype it, GitHub rejects the file withUnexpected value 'branch'.- Forgetting checkout. The runner starts empty, so every command that needs the repo's files fails.
- Swapping
usesandrun. Actions useuses, terminal commands userun.
TL;DR: A GitHub Actions workflow (an automated list of steps on GitHub's CI/CD service) is written in YAML in .github/workflows/. on sets the events (things that happen in the repo) that trigger it: push and pull_request, with branches: [main] to limit the branches. jobs holds jobs that each run on a new runner (a virtual machine from GitHub, runs-on: ubuntu-latest), and the steps inside run in order. uses: owner/repo@version runs an action (ready-made code written by someone else), for example actions/checkout@v7, which is needed first because the runner starts empty. run: runs a shell command. A failed step stops the job, and the reason is right above Error: Process completed with exit code ....
⚡ The place must be exact
Write:
.github/workflows/ci.yml
Guess first: you put the workflow file in .github/workflow/, with no s. What error shows up?
None at all. GitHub only reads .github/workflows/, so a folder one letter s short is ignored without any message.
Meaning: A GitHub Actions workflow file (an automated list of steps that GitHub runs) must be in .github/workflows/. Every .yml or .yaml file in that folder is one workflow.
⚡ on: when the workflow runs
Write:
on:
push:
branches: [main]
pull_request:
branches: [main]
Meaning: on lists the events (things that happen in the repo) that start the workflow. Here the workflow runs on every push to main, and every time a pull request (a request to merge a branch) into main is opened or gets a new commit. A push to another branch triggers nothing.
⚡ A runner starts as an empty machine
Write:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
- run: npm ci
- run: npm test
Meaning: The test job (a group of steps that run on one machine) runs on a runner, a new Ubuntu virtual machine from GitHub (runs-on: ubuntu-latest). Its steps run in order from the top. That machine doesn't have your repo's code yet, so actions/checkout (which copies the repo's code onto that machine) must come first. Without checkout, npm ci can't find package.json.
⚡ uses or run
Write:
- uses: actions/checkout@v7
- run: npm test
Meaning: uses runs an action (ready-made code written by someone else), written owner/repo@version. run runs a shell command on the runner. A failed step stops the job, and the reason is right above Error: Process completed with exit code ....