What is GitHub Actions and how do workflows, jobs, and steps work?
Learn how GitHub Actions works, including how workflows, jobs, and steps fit together to automate CI/CD pipelines directly inside your GitHub repository.
Expected Interview Answer
GitHub Actions is GitHub's built-in CI/CD platform that automatically runs automated processes in response to repository events, defined in YAML files under .github/workflows.
A workflow is a top-level automated process triggered by events like push or pull_request. Each workflow contains one or more jobs, which run in parallel by default (or sequentially via needs) on separate runners. Every job is made of steps that execute in order — a step either runs a shell command or invokes a reusable action, and all steps in a job share the same runner and filesystem.
- Native to GitHub, no external CI service to configure
- Event-driven automation for builds, tests, and deploys
- Reusable community actions from the Marketplace
- Parallel jobs speed up pipelines
- Matrix builds test many environments at once
AI Mentor Explanation
A workflow is a full match scheduled when a fixture is triggered. Each innings is a job that can be played on its own pitch, sometimes in parallel across grounds. Within an innings, every ball bowled is a step executed in strict order, and all balls share the same pitch and conditions just as steps share one runner and filesystem.
Step-by-Step Explanation
Step 1
Create the workflow file
Add a YAML file under .github/workflows/, for example ci.yml, in your repository.
Step 2
Define triggers
Use the on key to declare events like push, pull_request, or schedule that start the workflow.
Step 3
Declare jobs
Under jobs, list one or more jobs and set runs-on to pick the runner image such as ubuntu-latest.
Step 4
Add steps
Inside each job, list steps that either run shell commands or use published actions like actions/checkout.
Step 5
Order jobs
Use needs to make jobs run sequentially, otherwise jobs execute in parallel.
What Interviewer Expects
- Correct hierarchy of workflow, job, and step
- Understanding that jobs run in parallel by default
- Knowing steps in a job share a runner and filesystem
- Awareness of event-driven triggers via the on key
- Familiarity with using actions versus run commands
Common Mistakes
- Saying jobs run sequentially by default when they run in parallel
- Confusing steps with jobs
- Assuming filesystem is shared across separate jobs
- Forgetting the workflow file must live in .github/workflows
- Not knowing needs is required to order jobs
Best Answer (HR Friendly)
“GitHub Actions is a tool built into GitHub that automatically runs tasks like testing and deploying whenever something happens in the code, such as a push. You describe those tasks in a simple file, grouping them into jobs and smaller steps that run in order.”
Code Example
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm testFollow-up Questions
- How do you make one job wait for another to finish?
- What is a matrix strategy and when would you use it?
- How do actions differ from run commands?
- What events can trigger a workflow?
- How is data shared between jobs on different runners?
MCQ Practice
1. By default, how do jobs in a workflow run relative to each other?
Jobs run in parallel by default; you use the needs keyword to force sequential ordering.
2. Where must GitHub Actions workflow files be stored?
GitHub only recognizes workflow YAML files placed in the .github/workflows/ directory.
3. What do all steps within a single job share?
Steps in one job execute on the same runner and share its filesystem and working directory.
Flash Cards
What is a workflow? — A top-level automated process defined in YAML under .github/workflows, triggered by repository events.
How do jobs run by default? — In parallel, each on its own runner, unless ordered with the needs keyword.
What is a step? — A single unit inside a job that runs a shell command or invokes an action, executed in order.
What triggers a workflow? — Events declared under the on key, such as push, pull_request, or schedule.
Continue Learning
Related Interview Questions
What is a GitHub Actions runner and what is the difference between hosted and self-hosted runners?
medium
What is CI/CD and what problems does it solve in software delivery?
easy
What is the difference between continuous integration, continuous delivery, and continuous deployment?
medium
What is a CI/CD pipeline and what are its typical stages?
medium