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?