C.W.K.
Stream
Lesson 03 of 12 · published

Jobs

~12 min · jobs, parallelism, dependencies

Level 0Apprentice
0 XP0/101 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Each job is its own VM

A job is a unit of work that runs on a single runner (a VM or container). Jobs in the same workflow run in parallel by default — that's the main reason you split work into multiple jobs.

Important consequences:

  • Each job starts with a clean working directory. Files created in one job are not visible to another. Pass artifacts between jobs explicitly with upload-artifact + download-artifact.
  • Each job's runner is a fresh VM. Caches must be re-hydrated.
  • Jobs can declare needs: to wait on other jobs and form a DAG.
  • Jobs can declare if: conditions to skip based on context.

Anatomy of a job

  • runs-on — required. The runner label (ubuntu-latest, macos-14, self-hosted, etc.).
  • steps — required. The list of commands or actions, run in order on this runner.
  • needs — optional. Other jobs this one depends on.
  • if — optional. Expression that gates the whole job.
  • strategy — optional. Matrix expansion (we'll cover later).
  • env — optional. Job-scoped env vars.
  • outputs — optional. Values published to dependent jobs.
  • environment — optional. Production-style gating with approvals.

Code

Three-job DAG: build → (test, lint) → deploy·yaml
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm run build
      - uses: actions/upload-artifact@v4
        with: { name: dist, path: dist/ }

  test:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm test

  lint:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm run lint

  deploy:
    needs: [test, lint]
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with: { name: dist }
      - run: ./deploy.sh

External links

Exercise

Take a workflow that has one big job with lint + test + build. Split it into three jobs running in parallel. Time the before-and-after wall clock. Note any new upload-artifact / download-artifact coordination you needed.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.