Git & GitHub Interview Question #105
What are reusable workflows in GitHub Actions?
Advanced GitHub Actions, Repository Internals, Submodules, LFS & Diagnostic Tools Senior Advanced
Quick Interview Answer
Reusable workflows allow one workflow to call another workflow so common CI or deployment logic can be maintained centrally. They reduce duplication across repositories or multiple pipelines within an organization.
Detailed Explanation
Reusable workflows allow one workflow to call another workflow so common CI or deployment logic can be maintained centrally. They reduce duplication across repositories or multiple pipelines within an organization.
The reusable workflow defines a workflow_call trigger and can accept inputs and secrets. Callers should pin trusted workflow versions appropriately and keep interfaces clear.
Code Example
# Reusable workflow
on:
workflow_call:
inputs:
configuration:
required: true
type: string
# Caller
jobs:
build:
uses: owner/repo/.github/workflows/build.yml@main
with:
configuration: Release