🎓 A1Learner
🔍
0 of 50 lessons completed

GitHub Actions: Reading a Workflow Line by Line

A workflow file is a short YAML file that tells GitHub what to do. Every line in it has one clear job.

The name line

The name is the title GitHub shows for the workflow.

name: CI

The trigger line

The on line says when the workflow starts.

on: push

The jobs block

Jobs hold the work. This workflow has one job, called test.

jobs:
  test:

The runner line

The runs-on line picks the machine for the job.

    runs-on: ubuntu-latest

The steps block

Steps run in order on the same runner.

    steps:
      - uses: actions/checkout@v7
      - run: npm test

A setup step

Some steps need extra settings. The with block holds them.

      - uses: actions/setup-node@v7
        with:
          node-version: '24'

Example

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 test

Key points

  • Use name to give the workflow a title that shows in the Actions tab.
  • Use on to say which event starts the workflow.
  • Use jobs to list the work the workflow runs.
  • Use runs-on to pick the runner for a job.
  • Use steps to list the actions a job runs in order.
  • Use uses to run a ready-made action in a step.
  • Use run to run a shell command in a step.
  • A workflow file is a short list of named blocks, not a program.

In this example, the workflow is the same ci.yml file from the first workflow lesson. The name line calls it CI. The on line starts it on every push. The test job runs on the latest Ubuntu runner. Its steps fetch the code, set up Node 24, and run the tests. The output shows both tests passing.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

Which line picks the machine a job runs on?