Java Backend Interview Q&A← All stacks

GitHub Actions — Interview Q&A Matrix

Parent stack: CI/CD Technology: GitHub Actions Levels: Junior · Senior · Architect Questions: 5

Each entry contains a Question, the Expected Depth, an Ideal Answer, and Red Flags.

Junior

Q1 — Workflow structure and triggers

Question: What are the main parts of a GitHub Actions workflow, and how does a workflow start?

Expected Depth:

Ideal Answer:

yaml
name: CI

on:
  push:
    branches: [main]
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Print a message
        run: echo "Building commit $GITHUB_SHA"

Red Flags:


Q2 — Actions, dependency caching, and build speed

Question: How do you set up a language toolchain and cache dependencies so a build workflow runs faster?

Expected Depth:

Ideal Answer:

yaml
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: "21"
          cache: maven        # built-in dependency cache
      - run: mvn -B verify
yaml
      - uses: actions/cache@v4
        with:
          path: ~/.m2/repository
          key: maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            maven-

Red Flags:


Senior

Q3 — Secrets, token permissions, and untrusted input

Question: How do you keep a workflow secure when it handles secrets and runs on pull requests from forks?

Expected Depth:

Ideal Answer:

yaml
permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: ./gradlew build
        env:
          API_TOKEN: ${{ secrets.API_TOKEN }}
yaml
      - name: Print the title safely
        env:
          PR_TITLE: ${{ github.event.pull_request.title }}
        run: echo "Title is: $PR_TITLE"
yaml
      - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0

Red Flags:


Q4 — Reusable workflows, matrix builds, and concurrency

Question: How do you avoid duplicated pipeline code across many repositories, test several versions at once, and stop wasted runs?

Expected Depth:

Ideal Answer:

yaml
# .github/workflows/java-build.yml
on:
  workflow_call:
    inputs:
      java-version:
        type: string
        required: true

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: ${{ inputs.java-version }}
      - run: mvn -B verify
yaml
jobs:
  call-build:
    uses: ./.github/workflows/java-build.yml
    with:
      java-version: "21"
yaml
    strategy:
      fail-fast: false
      matrix:
        java: ["17", "21"]
yaml
concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true

Red Flags:


Architect

Q5 — CI/CD platform design: environments, OIDC, and runner strategy

Question: As the platform owner, how would you design GitHub Actions deployment pipelines for many teams so they are secure, auditable, and consistent?

Expected Depth:

Ideal Answer:

yaml
jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: production
    steps:
      - run: ./deploy.sh
yaml
permissions:
  id-token: write
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::111122223333:role/deploy
          aws-region: eu-west-1

Red Flags:


Scoring Rubric

Level Pass bar
JuniorExplains workflow structure, triggers, actions, and caching correctly.
SeniorSecures tokens and secrets and shares pipeline logic with matrices and concurrency.
ArchitectDesigns environment protection, OIDC, runner strategy, and organization-wide standards.