Interview Q&A · questions with model answers
GitHub Actions Fundamentals Interview Questions
Part of the study plan for: DevOps Engineer
Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.
-
Most asked Explain how a GitHub Actions workflow is structured: events, jobs, steps, runners and actions.
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…
-
Most asked How do you keep secrets safe in GitHub Actions, and why use OIDC to reach the cloud?
Store secrets in repository, organisation or environment secrets (never in the YAML), give the GITHUB_TOKEN the least permissions it needs, and prefer OIDC federation to cloud providers: the…
-
Most asked Write a GitHub Actions workflow that tests, builds and pushes a Docker image, and deploys only from main.
Run tests on every push and pull request, build the image tagged with the commit SHA, push it only for main, and deploy in a separate job that needs the build and targets a protected production…
-
How do you speed up slow GitHub Actions workflows?
Measure which jobs and steps are slow, then cache dependencies and Docker layers, split work into parallel jobs or a matrix, skip work that the change doesn't affect (path filters), cancel…
-
Reusable workflows or composite actions: what's the difference, and when do you use each?
A composite action bundles steps into one step you can uses: inside a job; it runs on the caller's runner. A reusable workflow (on: workflow_call) is a whole workflow with its own jobs, runners,…
-
How do you add approval gates to deployments in GitHub Actions?
Create a production environment with required reviewers (and optionally a wait timer and a branch rule that only allows main), and target it from the deploy job with environment: production. The job…
-
Why should you pin third-party actions to a commit SHA?
Tags such as @v3 can be moved by the action's owner or an attacker who compromises the repository, so your workflow would run new, unreviewed code with access to your secrets and token. A full…
-
What are the security risks of pull_request_target and self-hosted runners?
pull_request_target runs in the context of the base repository with secrets and a write token; if it checks out and runs code from the pull request, an attacker's fork can steal secrets. Self-hosted…
-
How does the GITHUB_TOKEN work, and how do you limit its permissions?
GitHub creates a GITHUB_TOKEN for each workflow run, scoped to the repository and valid only while the job runs. Its permissions come from the repository or organisation default and the workflow's…
-
A workflow passes on main but fails for pull requests from forks. Why?
Most likely the workflow needs secrets or write permissions, and GitHub deliberately withholds secrets and gives a read-only token to pull_request runs from forks. Steps that log in to a registry,…
-
How do you run a matrix build, and how do you stop one failing combination cancelling the rest?
Define a strategy.matrix with the dimensions to test (versions, operating systems); GitHub runs one job per combination. Set fail-fast: false so the other combinations finish when one fails, and use…