GitHub Actions: YAML in Ten Minutes
YAML is the plain-text format that workflow files use. It uses spaces and simple lines, with no brackets.
A map
Each line pairs a name with a value.
name: CI
runs-on: ubuntu-latestA list
Each item starts with a dash and a space.
steps:
- uses: actions/checkout@v7
- run: npm testA string
Quotes keep 24 as text, not a number.
node-version: '24'Indentation
Two spaces show that test belongs to jobs.
jobs:
test:
runs-on: ubuntu-latestA comment
A # starts a note that GitHub ignores.
# runs the tests
- run: npm testExample
name: CI
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '24'
- run: npm testKey points
- YAML: a plain-text format for settings and lists.
- Indent with two spaces per level.
- A map is a set of name and value pairs.
- A list is a set of items, each starting with a dash.
- A string is plain text, with quotes only when needed.
- Never use tabs in YAML. Tabs break the file.
- A comment starts with #. GitHub ignores comments.
- YAML is just indented lines. Spaces show what belongs together.
In this example, the whole CI workflow shows every YAML idea at once. The name line is a map pair. The on line is a map pair too. The jobs line opens a map, and test sits two spaces inside it. The steps line opens a list, and each dash starts one step. The with block sits under setup-node, and node-version is a quoted string. A later lesson reads this file line by line.
Note
A missing space after a colon breaks the line. Write name: CI, not name:CI.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
How do you show nesting in YAML?