GitHub Actions Fundamentals interview question · Most asked
Explain how a GitHub Actions workflow is structured: events, jobs, steps, runners and actions.
How it works Asked in DevOps Engineer interviews
Summary
A workflow is a YAML file in .github/workflows/ triggered by events (push, pull_request, schedule,
workflow_dispatch). It contains jobs that run in parallel by default (or in order with needs), each on a
runner (a GitHub-hosted or self-hosted machine). A job is a list of steps; a step either runs a shell
command (run) or uses an action (uses: actions/checkout@v4).
Longer Answer
- Each job gets a fresh runner; share data between jobs with artifacts or job outputs, and speed up with caches.
- Contexts and expressions:
${{ github.ref }},${{ secrets.X }},if: github.event_name == 'push'. - Matrix runs one job definition across versions or platforms.
- Environments add protection rules (required reviewers, wait timers, branch restrictions) and environment-scoped secrets.
- Concurrency groups cancel or queue overlapping runs.
Example
name: CI
on:
pull_request:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 22, cache: npm }
- run: npm ci
- run: npm test
Key Points
- Events trigger workflows; jobs run on runners.
- Steps run commands or actions.
- Jobs are parallel unless linked with needs.
- Artifacts, outputs and caches move data between jobs.
Explanation
What interviewers look for
A correct mental model of what runs where, and how jobs share data.
More GitHub Actions Fundamentals questions
- How do you keep secrets safe in GitHub Actions, and why use OIDC to reach the cloud?
- Write a GitHub Actions workflow that tests, builds and pushes a Docker image, and deploys only from main.
- How do you speed up slow GitHub Actions workflows?
- Reusable workflows or composite actions: what's the difference, and when do you use each?
- How do you add approval gates to deployments in GitHub Actions?
- Why should you pin third-party actions to a commit SHA?
- What are the security risks of pull_request_target and self-hosted runners?
- How does the GITHUB_TOKEN work, and how do you limit its permissions?