Interview questions with answers
GitHub Actions interview questions and answers
Workflows, jobs, runners, secrets, caching, matrices and OIDC. Open any question to read its model answer; the multiple-choice set marks the right option and explains it.
- Subjective
- 30
- Objective
- 30
Subjective questions 30
1Explain workflows, jobs, steps and runners.Asked almost every time
A workflow is a YAML file in .github/workflows/ triggered by events. It contains jobs, which run in parallel by default on runners (GitHub-hosted VMs or your self-hosted machines). Each job has steps that run shell commands (run) or reusable actions (uses). Jobs share no files unless you pass artifacts or outputs; needs makes one job wait for another.
2How do you handle secrets safely?Asked almost every time
Store them as repository, environment or organisation secrets and reference them as ${{ secrets.NAME }}; they are masked in logs. Give the GITHUB_TOKEN minimal permissions, avoid exposing secrets to pull requests from forks, protect production with environments that need approval, and prefer OIDC to long-lived cloud keys.
3How do you deploy to a cloud without storing long-lived keys?Asked almost every time
Use OpenID Connect: grant the job permissions: id-token: write, configure a trust policy in the cloud (for example an AWS IAM role trusting GitHub's OIDC provider for a specific repository and branch), and use the provider's action (such as aws-actions/configure-aws-credentials) to get short-lived credentials at run time.
4How would you design a CI/CD pipeline with GitHub Actions?Asked almost every time
On pull requests: install with caching, lint, type-check, run unit tests in a matrix, build, and run end-to-end tests, with required status checks. On merge to main: build once, publish an artifact or image, deploy to staging, run smoke tests, then deploy to production through a protected environment with approval, using OIDC for cloud credentials.
5How do you use caching effectively?Asked almost every time
Use actions/cache or the built-in cache option of setup actions (for example actions/setup-node with cache: npm). Key caches on the lockfile hash with restore-keys as fallback, cache dependency stores rather than node_modules when possible, and keep caches under the size limit.
6How do you keep workflows secure?Asked almost every time
Set minimal permissions (default read), pin third-party actions to SHAs, avoid pull_request_target with untrusted code, never echo secrets, use environments with approvals for deploys, use OIDC instead of long-lived keys, review workflow changes in code review, and enable Dependabot for actions.
7How do you speed up workflows?Very often asked
Cache dependencies (actions/cache or the built-in cache of setup-node), run independent jobs in parallel, split tests with a matrix or sharding, use path filters so unrelated changes skip jobs, cancel outdated runs with concurrency, and use larger or self-hosted runners for heavy builds.
8What is a matrix strategy?Very often asked
strategy.matrix runs a job once per combination of values, such as Node 20 and 22 on Ubuntu and Windows. include and exclude adjust combinations, fail-fast controls whether one failure cancels the rest, and max-parallel limits concurrency.
9Reusable workflows vs. composite actions?Very often asked
A reusable workflow (on: workflow_call) is a whole workflow with its own jobs, called from other workflows with inputs and secrets, good for shared pipelines. A composite action bundles several steps into one action used inside a job, good for shared setup such as 'install and cache dependencies'.
10How do you pass data between jobs?Very often asked
Small values: set step outputs (echo "name=value" >> $GITHUB_OUTPUT), expose them as job outputs, and read them with needs.<job>.outputs.name. Files: upload with actions/upload-artifact and download with actions/download-artifact in a later job.
11What does concurrency do?Very often asked
It groups runs by a key (for example the branch) so only one runs at a time; with cancel-in-progress: true a new push cancels the outdated run. It saves minutes and prevents overlapping deployments.
12What are artifacts vs. caches?Very often asked
Artifacts are files produced by a run (builds, test reports) that you upload to share between jobs or download later. Caches speed up repeated work (dependencies) across runs and may be evicted. Do not use caches to pass build outputs.
13How do path filters and conditions save time?Very often asked
on.push.paths and paths-ignore run workflows only when relevant files change. if: conditions skip jobs or steps, for example deploying only on main. In monorepos, tools like dorny/paths-filter decide which packages to test.
14How do you write a custom JavaScript action?Very often asked
Create action.yml declaring inputs, outputs and runs: using: node20 with an entry file, use @actions/core to read inputs and set outputs and @actions/github for the API, bundle dependencies (for example with ncc) and tag releases.
15How do you deploy a static site or app to GitHub Pages?Very often asked
Build in a job, upload with actions/upload-pages-artifact, then deploy with actions/deploy-pages in a job that has pages: write and id-token: write permissions and the github-pages environment.
16How do you handle flaky tests in CI?Very often asked
Track them with test reports, quarantine or fix them, add limited retries in the test runner rather than rerunning whole workflows, make tests deterministic (fixed data, mocked time), and upload traces or screenshots on failure.
17What does GITHUB_TOKEN do?Very often asked
An automatically created, short-lived token scoped to the repository for each job, used to call the GitHub API, push, comment or publish packages. Its rights come from the permissions key; events it triggers usually do not start new workflows, which prevents loops.
18What are environments and protection rules?Often asked
Environments (such as staging and production) hold their own secrets and variables and can require reviewers' approval, wait timers or allowed branches before a job referencing them runs. They give deployment history and gates.
19What security risks exist with pull_request_target?Often asked
It runs with the base repository's permissions and secrets, even for pull requests from forks. Checking out and running the fork's code in it can leak secrets or allow tampering. Use pull_request for untrusted code, and if you need pull_request_target, never run untrusted code in it.
20Why pin actions to a commit SHA?Often asked
Tags such as @v4 can be moved to different code, so a compromised action could run in your pipeline. Pinning to a full commit SHA makes it immutable; tools like Dependabot can still update the pins.
21What are self-hosted runners and their risks?Often asked
Your own machines registered to run jobs, useful for special hardware, private networks or cost. Risks: they persist between jobs, so untrusted code (especially from public forks) can compromise them; use ephemeral runners, isolation and keep them off public repositories.
22How do you build and push Docker images?Often asked
Use docker/setup-buildx-action, log in with docker/login-action (GITHUB_TOKEN for GHCR), and docker/build-push-action with layer caching (cache-from: type=gha). Tag with the commit SHA and version, and sign or attest images for provenance.
23What are larger runners and ARM runners?Often asked
GitHub-hosted runners with more CPU and memory, GPUs or ARM64 architecture, configured at the organisation level. They speed up heavy builds or test native ARM, at a higher cost per minute.
24How do you debug a failing workflow?Often asked
Read step logs, enable debug logging with the ACTIONS_STEP_DEBUG secret or by re-running with debug logging, print contexts with toJSON(github), reproduce locally with act, or add a temporary SSH debugging step on a private repository.
25How do status checks and branch protection work together?Often asked
Workflows report status checks on commits; branch protection rules or rulesets can require specific checks to pass, plus reviews, before merging. Use stable job names so required checks match.
26What is workflow_run?Often asked
A trigger that starts a workflow when another workflow completes, for example deploying after CI succeeds or posting results from a fork-safe second workflow that has write permissions.
27How do you limit workflow minutes and cost?Often asked
Cancel superseded runs with concurrency, use path filters, cache dependencies, split slow jobs, set timeout-minutes, use smaller matrices on pull requests and fuller ones nightly.
28How do you trigger a workflow manually or on a schedule?Sometimes asked
on: workflow_dispatch (with optional inputs) adds a 'Run workflow' button and API trigger. on: schedule with a cron expression runs it periodically in UTC; scheduled runs use the default branch.
29What are expressions and contexts?Sometimes asked
${{ }} expressions evaluate values from contexts such as github (event data), env, secrets, matrix, needs and steps, and functions like contains(), success() or failure() in if: conditions.
30How do you generate build provenance?Sometimes asked
Use actions/attest-build-provenance to create signed attestations linking an artifact to the workflow run that built it, which consumers can verify with the GitHub CLI.
Objective questions 30
1Where are workflow files stored?Asked almost every time
Why: GitHub reads YAML files from .github/workflows.
2How do jobs run by default?Asked almost every time
Why: Use needs to make one wait for another.
3How do you reference a secret?Asked almost every time
Why: The secrets context exposes stored secrets.
4What should the default token permission be?Asked almost every time
Why: Least privilege.
5What is a good cache key for npm dependencies?Asked almost every time
Why: Changes when dependencies change.
6Which pair is needed to deploy to GitHub Pages with actions?Asked almost every time
Why: Plus pages: write permission.
7Which key makes a job wait for another?Very often asked
Why: needs: build runs after the build job.
8Which permission is required for OIDC cloud login?Very often asked
Why: It lets the job request an OIDC token.
9Which feature cancels outdated runs on the same branch?Very often asked
Why: Concurrency groups runs and can cancel old ones.
10Which action stores files for a later job?Very often asked
Why: Artifacts move files between jobs and keep them after the run.
11Artifacts are for…Very often asked
Why: Caches are for dependencies.
12Which key stops a job that runs too long?Very often asked
Why: Default is 360 minutes.
13Which trigger runs after another workflow completes?Very often asked
Why: Used for chained pipelines.
14Which filter runs a workflow only when certain files change?Very often asked
Why: Saves minutes.
15Events created with GITHUB_TOKEN usually…Very often asked
Why: Prevents recursion.
16Which trigger adds a manual 'Run workflow' button?Often asked
Why: workflow_dispatch allows manual runs.
17What does on: workflow_call make a workflow?Often asked
Why: Reusable workflows are invoked with uses:.
18Which is the safest way to reference a third-party action?Often asked
Why: SHAs cannot be moved to new code.
19Where do steps write outputs?Often asked
Why: Append name=value lines to $GITHUB_OUTPUT.
20Which file defines a custom action?Often asked
Why: Inputs, outputs and runs.
21Which cache backend does build-push-action use with GitHub?Often asked
Why: GitHub Actions cache.
22Which tool runs workflows locally?Often asked
Why: Approximates the runner.
23How do you print the full github context?Often asked
Why: Useful for debugging.
24Which action logs in to a container registry?Often asked
Why: Works with GHCR and others.
25Branch protection can require…Often asked
Why: Blocks merging on failure.
26Scheduled workflows use which time zone?Sometimes asked
Why: Cron schedules are in UTC.
27Which job-level key limits the token's rights?Sometimes asked
Why: Set least-privilege permissions for GITHUB_TOKEN.
28Which condition runs a step only when an earlier one failed?Sometimes asked
Why: failure() is true when a previous step failed.
29Which action creates signed build provenance?Sometimes asked
Why: Verified with the gh CLI.
30Which secret enables step debug logs?Sometimes asked
Why: Set to true.
Track what you have practised and search every bank in your dashboard.
Start learning