Script Valley
CI/CD with GitHub Actions
Building a CI PipelineLesson 2.4

How to run jobs in parallel and in sequence using needs

parallel jobs, needs keyword, job dependency graph, fan-out pattern, fan-in pattern, job status checks, sequential pipeline

Jobs Run in Parallel by Default

Parallel vs sequential jobs

By default, all jobs in a workflow start simultaneously. This is efficient but sometimes wrong — you cannot deploy before tests pass.

The needs Keyword

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm run lint

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

  build:
    runs-on: ubuntu-latest
    needs: [lint, test]    # waits for both to pass
    steps:
      - uses: actions/checkout@v4
      - run: npm run build

needs accepts a single job ID or an array. The job waits until all listed jobs complete successfully. If any dependency fails, the dependent job is skipped by default.

Fan-Out and Fan-In

This pattern — multiple parallel jobs converging into one — is called fan-out/fan-in. It is common in CI: lint and test run in parallel (fan-out) and build only runs when both pass (fan-in). This reduces total pipeline duration compared to a purely sequential approach.

Up next

How to upload and download build artifacts in GitHub Actions

Sign in to track progress