DevOpsInterview.Cloud
CI/CD

GitHub Actions - Reusable Workflows Explained

2 min read

A team maintains the same test-build-deploy workflow copy-pasted across fifty repos. When one step needs to change, someone has to edit fifty files and inevitably misses a few. This comes up in interviews because it's a cheap way to check if a candidate has actually operated a GitHub Actions setup at scale, or just written one-off pipelines for a side project.

The answer interviewers want

Reusable workflows are essentially functions for your CI/CD. You write the logic once and call it from anywhere, passing in different inputs each time, instead of maintaining fifty near-identical copies of the same YAML.

To build one, create a workflow file under .github/workflows/, and inside it add a workflow_call trigger:

on:
  workflow_call:
    inputs:
      environment:
        required: true
        type: string

Any other workflow can then call it with the uses keyword instead of duplicating the steps:

jobs:
  deploy:
    uses: my-org/my-repo/.github/workflows/deploy.yml@v1.2.0
    with:
      environment: staging

The detail that trips people up: always version your reusable workflows with tags, never reference main in production. If you call a reusable workflow at @main, someone can merge a breaking change to that branch and silently break every single pipeline that depends on it, with no warning and no rollback path. Pinning to a tag like @v1.2.0 means consumers only pick up changes when they explicitly bump the version, the same discipline you'd apply to any shared library dependency.

Done right, this eliminates copy-paste workflows cluttering your repos and gives you one place to fix bugs or add steps.

Why interviewers ask this

This question separates people who've only written standalone CI configs from people who've had to maintain CI/CD across many repos or teams. It also tests whether you think about reusable workflows as production dependencies that need versioning discipline, not just as a copy-paste shortcut. Interviewers want to hear you connect the dots between duplication pain and the fix, not just recite the workflow_call syntax.

Follow-ups to expect

  • What happens if you reference a reusable workflow by @main instead of a tag? A breaking change merged to main propagates instantly to every caller, with no version boundary to catch it before it hits production pipelines.
  • How do you pass different configuration into the same reusable workflow for different environments? Define inputs in the workflow_call trigger, then pass values with with when another workflow calls it via uses.
  • How is this different from a composite action? The source material doesn't cover composite actions directly, but it's worth being ready to contrast the two, since interviewers often ask when to use each.

The common wrong answer

Candidates usually describe reusable workflows correctly in theory, the write-once, call-from-anywhere idea, but forget the versioning requirement entirely. They say something like "you reference it with uses" and stop there, without mentioning that pointing at main instead of a tagged version is exactly how one team's innocuous commit turns into a fleet-wide pipeline outage. That omission is usually what separates a pass from a borderline answer.

Prefer it spoken? Watch the 30-second answer on YouTube

More CI/CD questions