CI/CD Scenario Based Interview Questions: GitHub Actions, Flaky Tests and Bad Deploys
- 16 min read
The short answer
CI/CD scenario questions test whether you keep the safety gates while making the pipeline faster. Speed up tests instead of skipping them, reproduce CI failures instead of retrying, use OIDC instead of stored cloud keys, pin actions to commit SHAs, roll back first during an incident, and prefer automated guardrails over blanket manual approvals.
Junior CI/CD questions ask for definitions: what is continuous integration, what is the difference between delivery and deployment, what is a runner. Experienced candidates usually get a different kind of question. The interviewer describes a slow pipeline, a red build, a leaked credential or a bad release, and asks what you would do. Then they argue with you.
Below are six common CI/CD scenarios, mostly in GitHub Actions, each with the prompt, the YAML or commands you would reach for, the pushback to expect, and a weak answer next to a strong one. For the general shape of a DevOps loop, see how to pass a DevOps interview.
What these questions are really testing
Three things, in every scenario below:
- Do you keep the gate while fixing the speed? Almost every CI/CD shortcut removes a check (tests, review, a rollback path) to save minutes. A strong answer makes the check cheaper instead of deleting it.
- Do you know what the pipeline can reach? A CI job runs third-party code with credentials. What
GITHUB_TOKENcan do, which secrets a job sees, and which actions it pulls are security questions, not YAML trivia. - Do you optimize for recovery? Bad deploys will happen. The question is how fast you get back to a known-good version and how small each change is.
A weak answer names a feature. A strong one says what it changes about risk and what you will check to prove it.
Scenario 1: "The pipeline takes 40 minutes, so skip the tests"
The prompt: "Your deploy pipeline takes 40 minutes, and the team is frustrated. A teammate proposes skipping the test stage so releases ship faster. Do you agree, and what do you do instead?"
Say no to removing the gate, and yes to the real problem. Then find out where the 40 minutes goes. gh run view shows per-job timings for a run:
gh run list --workflow deploy.yml --limit 5
gh run view 8412233190
JOBS
build in 6m12s (ID 23110001)
unit-tests in 4m03s (ID 23110002)
integration-tests in 13m41s (ID 23110003)
e2e-tests in 14m20s (ID 23110004)
deploy in 1m55s (ID 23110005)
(Trimmed: the real output also shows a status mark per job.) Each job waits for the one before it, nothing is cached, and the two slow suites are 28 of the 40 minutes. That points at four fixes, none of which drops a test:
jobs:
unit:
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
e2e:
needs: unit
runs-on: ubuntu-latest
strategy:
matrix:
shard: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx playwright test --shard=${{ matrix.shard }}/4
- Cache dependencies.
setup-nodewithcache: npmrestores the npm download cache keyed on the lockfile. - Split fast from slow. Unit tests give feedback in minutes; integration and e2e run in parallel jobs after them.
- Shard the slow suites. Playwright and Jest both accept
--shard=N/M, so a matrix spreads one suite across runners. - Build once. Build the artifact or image once and pass it to later jobs with
actions/upload-artifactandactions/download-artifact, instead of rebuilding per job.
One gotcha: path filters (on: pull_request: paths:) skip a whole workflow, and if it is a required status check, the skipped check stays pending and blocks the merge. Skip jobs inside a workflow that always runs instead.
The pushback: "Everyone runs tests locally before pushing. The CI stage is redundant, so dropping it is harmless, right?"
| Weak answer | Strong answer |
|---|---|
| "If people are disciplined, sure." | "Local runs happen on different machines, different versions and partial checkouts. CI is the only place the merged code is tested as a unit. That is the point of it." |
| "Fine, we skip them this week and turn them back on." | "Temporary skips tend to stay. Parallelizing and caching makes every future release faster, not just this one." |
The rest of the argument, which tests can run selectively, what to do about a real deadline today, and how to measure that the faster pipeline still catches regressions, is what the challenge scores you on. The free CI pipelines guide and caching guide cover the YAML in more depth.
Practice this one: /challenges/ci-skip-tests-to-ship
Scenario 2: "It passes locally, CI is just flaky, add a retry"
The prompt: "Your test suite passes on your laptop but fails in CI. A teammate says CI is just flaky, add a retry and re-run until it is green. What do you do, and why?"
This is the flaky tests interview question, and the trap is the word "flaky". A test that fails only in CI usually has a cause: OS, dependency versions, an env var, a timezone, test ordering or shared state. List what differs:
node --version && npm --version && date +%Z
git status --short package-lock.json
Then make your laptop look like the runner. GitHub-hosted Ubuntu runners use UTC, and many laptops do not:
TZ=UTC npm test -- --runInBand
FAIL src/billing/invoice.test.ts
* invoice due date > is the last day of the month
Expected: "2026-11-30"
Received: "2026-12-01"
That is a real bug in date handling, not CI noise. Two other common causes are worth checking out loud:
- Order dependence. Jest can shuffle test order with
--randomizeand replay a failing order with--seed. A test that fails only in some orders shares state, often a temp directory. - Unpinned inputs.
npm ciagainst a committed lockfile, notnpm install, which can resolve newer versions than your laptop has.
Retries have a place for genuinely external calls. Even then, track how often they fire and quarantine the test with an owner, so a retry is a visible exception, not a default.
The pushback: "It passes on the third run. Why not set retries to 3 and move on? Green is green."
| Weak answer | Strong answer |
|---|---|
| "Retries are standard practice, so yes." | "A retry that turns red into green hides the failure without explaining it. If this is a timezone bug, customers in other timezones hit it in production, where there is no retry." |
| "It works on my machine, so the code is fine." | "My machine is one environment. CI just showed me a second one where it fails. That is information, and it took me one command to reproduce." |
Practice this one: /challenges/flaky-ci-passes-locally
Scenario 3: "Paste the AWS access key into GitHub secrets"
The prompt: "The deploy job needs AWS permissions. A teammate created an IAM user, generated an access key and secret, and wants to store them as GitHub Actions secrets so the pipeline can deploy. Do you agree, and what do you do instead?"
This is the most common GitHub Actions security question. A long-lived key works from anywhere until someone rotates it, and anyone who can change a workflow can make a job use it. The better option is OpenID Connect: each run gets a signed token from GitHub, trades it with AWS STS for short-lived credentials, and nothing static is stored.
The workflow side:
name: deploy
on:
push:
branches: [main]
permissions:
id-token: write # lets the job request an OIDC token
contents: read # still needed for actions/checkout
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::123456789012:role/gha-deploy-myapp
aws-region: eu-west-1
- run: aws sts get-caller-identity
{
"UserId": "AROAEXAMPLEID:GitHubActions",
"Account": "123456789012",
"Arn": "arn:aws:sts::123456789012:assumed-role/gha-deploy-myapp/GitHubActions"
}
Note the permissions block. Once you set any permission explicitly, every scope you do not list is set to none, which is why contents: read has to be there for checkout.
The AWS side is an IAM OIDC identity provider for token.actions.githubusercontent.com and a role whose trust policy says exactly who may assume it:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::123456789012:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
"token.actions.githubusercontent.com:sub": "repo:acme/myapp:environment:production"
}
}
}
]
}
The sub condition is the part interviewers probe. Without it, workflows in other repositories could assume the role. Because the job references the production environment, the subject is repo:acme/myapp:environment:production; without an environment, a push to main produces repo:acme/myapp:ref:refs/heads/main. Scope it to one repo and one branch or environment, and give the role only what the deploy needs (push to one ECR repository, update one ECS service), not the broad policy the teammate attached "to be safe".
The pushback: "We already rotate keys on a schedule and scope the IAM user. That is basically the same security posture as OIDC, right?"
| Weak answer | Strong answer |
|---|---|
| "If rotation is enforced, it is close enough." | "Rotation shortens how long a leaked key works, from forever to weeks. OIDC credentials expire after an hour by default and only exist inside a run that matched the trust policy. And this team has no rotation process yet." |
| "The repo is private, so the key is safe." | "Private limits who can read the code, not who can edit a workflow. Anyone with write access can add a step that uses the secret. With OIDC, the trust policy decides which branch or environment can deploy." |
The rest of the argument, how to roll this out across the org's other repos without copying one shared role, and what the trust policy should allow for pull requests, is what the challenge scores you on. The free secrets and security guide covers OIDC and GITHUB_TOKEN permissions in more depth.
Practice this one: /challenges/github-actions-oidc-vs-keys
Scenario 4: "The action we use was hijacked, just bump the tag"
The prompt: "A popular third-party scanner action had its version tags moved to a malicious commit for about twelve hours. Your org references it as @v2 in around 40 repos, and scheduled jobs ran during that window. A teammate opened PRs bumping to the maintainer's new safe tag and wants to close the ticket because the logs look normal. Do you agree, and what do you do?"
This is a real pattern. In March 2025 the tags of tj-actions/changed-files were moved to a commit that dumped CI secrets into workflow logs (CVE-2025-30066). A git tag is a movable pointer, so @v2 means "whatever v2 points at when the job starts".
So this is an incident first and a version bump second. The order of the answer:
- Scope. List every run in the window that executed the action, and what each job could reach.
- Rotate long-lived secrets those jobs could reach, whether or not the logs look clean. A skim of the logs is weak evidence that nothing was taken.
- Hunt for misuse in that window: registry pushes, package publishes, cloud audit events, new tags, releases or workflow changes.
- Fix the class of problem. Stop trusting mutable references.
Resolve the tag you trust to a commit, check that commit, and pin to it:
git ls-remote --tags https://github.com/example-org/scanner-action 'v2*'
4f1c2a9e7b3d5c6a8e0f1b2c3d4e5f6a7b8c9d0e refs/tags/v2
4f1c2a9e7b3d5c6a8e0f1b2c3d4e5f6a7b8c9d0e refs/tags/v2.4.1
- uses: example-org/scanner-action@4f1c2a9e7b3d5c6a8e0f1b2c3d4e5f6a7b8c9d0e # v2.4.1
A full 40-character SHA cannot be moved the way a tag can. Dependabot or Renovate can bump both the SHA and the version comment, so pinning does not mean never updating. The org's allowed-actions policy can restrict which actions run at all, and a per-workflow permissions: block gives a compromised step a read-only GITHUB_TOKEN.
The pushback: "The cloud deploy uses OIDC, so there are no long-lived cloud keys. That means the cloud side is fine and we can skip it, right?"
| Weak answer | Strong answer |
|---|---|
| "Right, OIDC tokens expire, so nothing to do there." | "Nothing to rotate, but plenty to check. During the run the attacker's code could use the role like the job could. I read the cloud audit trail for that role across the window." |
| "The maintainer fixed it, so upgrading is all that is on us." | "The maintainer fixed their repo. The secrets that ran through our jobs are ours to rotate, and moving to another mutable tag trusts the same mechanism that just failed." |
Practice this one: /challenges/compromised-action-tag-response
Scenario 5: "Deployment failed in production: roll back or fix forward?"
The prompt: "Checkout error rate jumped from 0.1% to 9% right after release v412. You can roll back to v411 in about 2 minutes, or push a fix forward with an unknown ETA. What do you do, and why?"
This is the deployment failed in production interview question. The default is to restore service first and diagnose second, and the important word in the prompt is "unknown". A 2-minute rollback to a version that ran clean is a known cost. A patch written at 3 AM under pressure is a new, untested release.
Before you run it, check the one thing that can make rollback unsafe: did v412 include a database migration that v411 cannot run against, such as a dropped or renamed column? If the schema change was additive, rollback is safe. Then:
kubectl rollout history deployment/checkout
kubectl rollout undo deployment/checkout
kubectl rollout status deployment/checkout
deployment.apps/checkout rolled back
Waiting for deployment "checkout" rollout to finish: 2 of 6 updated replicas are available...
deployment "checkout" successfully rolled out
Then watch the error rate. If it does not return to baseline, v412 was not the cause, and you ruled out the top suspect in minutes. Either way, debug v412 in staging.
For the pipeline, rollback should mean "redeploy the previous artifact", which only works if every release is a versioned, immutable artifact. A deploy workflow should also set a concurrency group with cancel-in-progress: false, so two production deploys never overlap and none is cancelled halfway.
The pushback: "You do not actually know v412 caused this yet. What if rollback does not fix it and you have wasted the window?"
| Weak answer | Strong answer |
|---|---|
| "Good point, let's find the root cause first." | "The timing makes v412 the top suspect, and rollback is the cheapest test of that. If errors stay at 9%, I have learned it is not the deploy in two minutes, which is faster than any diagnosis." |
| "The teammate says the patch is one line, let's ship it." | "One line we have not tested, deployed during an incident. If it is wrong, we are on v413 with two problems. Roll back, then ship the fix through the normal pipeline." |
Practice this one: /challenges/rollback-vs-forward-fix
Scenario 6: "After the outage, every deploy needs a manual approval"
The prompt: "A bad deploy caused a two-hour outage. Leadership now wants a mandatory manual approval gate on every production deploy, where a lead signs off before anything ships. Do you agree, and what do you propose instead?"
The instinct is understandable, and the answer is still no. The research behind the DORA reports found that heavyweight external change approval was associated with slower delivery and was not associated with better stability. A lead approving several deploys a day cannot read each diff, so the gate becomes a rubber stamp, and the next fix waits for a sign-off.
Look at what caused this outage: thin tests on the affected path, a deploy to every instance at once, and a manual rollback. Each has an automated guardrail: tests on the path that broke, a canary or blue-green rollout so a bad version reaches a small slice of traffic first, automated rollback when error rate or latency crosses a threshold, and observability that shows a regression in minutes.
Human approval still fits genuinely high-risk or regulated changes. In GitHub Actions that is an environment with required reviewers, used only by the jobs that need it:
jobs:
migrate-billing-schema:
runs-on: ubuntu-latest
environment: production-high-risk # has required reviewers configured
The free CD deployments guide covers environments, protection rules and staged rollouts.
The pushback: "It is only one extra click per deploy. That is a tiny price to make sure this never happens again, so why push back at all?"
| Weak answer | Strong answer |
|---|---|
| "Fair, one click is cheap." | "The click does not make it never happen again. Would the lead have caught this bug by reading the diff? If not, the gate adds delay without catching the failure. A canary would have caught it on a few percent of traffic." |
| "Approvals are bad, we should not have any." | "I would keep human sign-off for schema migrations and other high-risk changes, and use automated guardrails for routine releases." |
Practice this one: /challenges/manual-approval-gate-after-outage
The same ideas in Jenkins
Jenkins scenario based interview questions test the same instincts with different nouns. Speed comes from parallel stages and stashing the build once. The retry step is the Jenkins version of re-run until green, with the same objection. withCredentials still binds a stored secret, so scope it tightly. Load shared libraries at a fixed commit (@Library('ci-lib@<commit>')) for the same reason you pin actions to a SHA, and disableConcurrentBuilds() plays the role of a concurrency group on deploy jobs.
More scenarios to practice
- "Just add a vulnerability scanner and we are secure." A scanner finds known-vulnerable packages, not a fresh malicious dependency or a CI job with broad production credentials. Practice it at /challenges/supply-chain-ci-hardening.
- "We deploy with SSH and git pull at 5pm Friday." git pull is not a deploy: no artifact, no health check, no one-step rollback. Practice it at /challenges/git-pull-deploy-friday.
- Image builds in CI. Layer caching, the Docker socket and secrets in layers are covered in the Docker scenario based interview questions.
The full set of pipeline prompts is on the CI/CD interview questions hub.
A pattern you can reuse in any CI/CD scenario
- Do not remove the gate yet. Say it first, whether the gate is tests, review, pinning or a rollback path.
- Measure before you change. Per-job timings for a slow pipeline, a reproduction for a red build, the run list for an incident window.
- Find the real difference. Environment, versions, ordering, or what changed between two releases.
- Shrink what the pipeline can reach. Explicit
permissions:, OIDC instead of stored keys, actions pinned to commit SHAs, separate trust levels for untrusted code. - Make recovery cheap. Versioned artifacts, one-step rollback,
concurrencyon deploys, canaries with automated rollback. - Name the trade-off. Retries for truly external flakiness, human approval for truly high-risk changes.
Practicing under pushback
Reading these answers is the easy part. In the interview, someone pushes back with a reasonable-sounding argument and watches whether you fold. A general chatbot makes up an answer on the spot. DevOps Ledger grades you against an answer key written before you started. Each scenario above has a challenge where you defend your call against that kind of pushback and see which arguments held up.
FAQ
What are CI/CD scenario based interview questions?
They describe a situation instead of asking for a definition: a slow pipeline, a test that fails only in CI, a credential in the wrong place, a hijacked dependency or a bad release. You are scored on what you check first, what you decide and how you defend it when the interviewer pushes back.
What GitHub Actions and CI/CD pipeline interview questions are asked for experienced engineers?
Expect security and reliability more than syntax: GITHUB_TOKEN permissions, OIDC to a cloud provider instead of stored keys, pinning actions to commit SHAs, the risks of pull_request_target, caching and matrix sharding for speed, environments with required reviewers, and concurrency groups for deploys.
How do you answer a flaky tests interview question?
Do not start with retries. Say a CI-only failure usually has a cause, then reproduce the CI environment: same timezone, same dependency versions from the lockfile, randomized test order. Fix the nondeterminism. Keep retries for genuinely external calls, and track and quarantine those tests with an owner.
Should you roll back or fix forward when a deployment fails in production?
During customer impact, default to rolling back to the last known-good version, after checking that no forward-only database migration blocks it. Fixing forward with an unknown ETA ships an untested change during an incident. Diagnose the bad release in staging once service is restored.
Why is pull_request_target risky in GitHub Actions?
It runs in the context of the base repository, with access to secrets and a token that can have write access, even for pull requests from forks. Checking out and running the PR's code under it hands those secrets to whoever opened the PR. Plain pull_request from a fork gets no secrets and a read-only token.
Practice these scenarios
- The Pipeline Is Slow. Skip Tests to Ship?
A 40-minute pipeline is blocking releases. A teammate wants to skip the test stage to ship faster. Defend your call.
- Tests Pass Locally, Fail in CI. Just Retry?
Your suite is green on your laptop but red in CI. A teammate wants to add a retry and re-run until green. Defend what you actually do.
- Deploy From CI: Paste AWS Keys Into GitHub Secrets?
Your GitHub Actions pipeline needs to deploy to AWS. A teammate wants to paste a long-lived IAM access key into repo secrets. Defend the better option.
- A GitHub Action You Use Was Hijacked. Bump the Tag and Move On?
A third-party scanner action your repos pin by tag was hijacked for half a day. A teammate bumped the tag and wants to close the ticket. Defend what you do.
- 3 AM Outage: Roll Back or Fix Forward?
A deploy 20 minutes ago correlates with a spike in 500s. You are on call. Defend whether to roll back or fix forward.
- After an Outage, Mandate Manual Approval on Every Deploy?
After a bad deploy caused an outage, leadership wants a mandatory human sign-off on every production release. Defend a better way to prevent the next one.
- Your CI Has Keys to Prod and Pulls Unpinned Deps
CI pulls unpinned dependencies, runs them, and holds prod credentials. A teammate says just add a vulnerability scanner. Defend a real hardening plan.
- Deploys Are SSH + git pull at 5pm Friday. Why Change It?
The team ships by SSHing into prod and running git pull, often at 5pm Friday. A teammate says it has always worked. Defend what a real deploy needs without cargo-culting.
Free guides to read next
Practice defending your decisions
DevOps Ledger is a scenario-based DevOps and SRE interview practice platform: you pick a real production incident, defend your decision in a chat against a senior-engineer AI that pushes back, and get scored against an answer key written before you started.
One payment. 12 months of access. No subscription, nothing renews.
Get full access - $19