Git & GitHub Course
Git & GitHub
/
Intermediate

Jobs & Steps

Definition

A Job is a set of Steps in a workflow that execute on the same runner. A Step is an individual task that can run commands in a job.

Explain Like I'm New

A Workflow is a factory. A Job is an assembly line in that factory (running on one specific server). A Step is a specific machine on that assembly line performing one distinct action.

Real World Example

Job 1: Build the App (Runs on Linux). Job 2: Test the App (Runs on Windows). Both jobs can run at the EXACT same time in parallel, slashing your wait time in half.

Common Use Cases

  • •Structuring complex CI/CD pipelines
  • •Running parallel tests

Terminal Output

bash / terminal
jobs: # JOB 1 (Runs instantly) build-app: runs-on: ubuntu-latest steps: - run: echo "Building the app..." # JOB 2 (Waits for Job 1 to finish) test-app: needs: build-app runs-on: ubuntu-latest steps: - run: echo "Testing the app..."

Interview Questions

basic

  • Do Jobs in a workflow run sequentially (one after another) or in parallel by default?

intermediate

  • How do you make Job B wait for Job A to finish?

Flash Cards

Question

Sequential or Parallel?

Click to reveal answer
Answer

By default, all Jobs run in parallel at the exact same time.

Question

Make Job B wait?

Click to reveal answer
Answer

Use the `needs` keyword. Example: `needs: [job-A]`.