Share pipelines with reusable workflows

DevOps, Hands On30 minutesFreeSteps checked 23 November 2026By Cloud Hands On

In this task you'll write a pipeline once and call it from many workflows.

Copying the same 60 lines of YAML into every repository means fixing every copy when something changes. A reusable workflow has on: workflow_call with typed inputs and secrets, and other workflows call it with uses: at job level. A composite action packs several steps into one step you can drop into any job.

Use a reusable workflow for a whole standard pipeline (test, build, scan) and a composite action for a few steps you repeat (set up the language and install packages). Call shared workflows by a tag or commit, not a moving branch, so a change in the shared file can't break every team at once.

Example. Fernhill Cloud's platform team keeps one python-ci.yml reusable workflow in a shared repository. Thirty services call it with uses: fernhill/pipelines/.github/workflows/python-ci.yml@v3 and pass only their Python version.

Before you start

You need: A free GitHub account and a public test repository (Actions minutes are free for public repositories). Time: 30 minutes.

Where to look

  1. Repository
  2. .github/workflows
  3. Actions tab

Steps

  1. Add .github/workflows/python-ci.yml with on: workflow_call and an input python-version (see Commands).
  2. Add .github/workflows/caller.yml that runs on push and calls it with uses: ./.github/workflows/python-ci.yml and python-version: '3.13'.
  3. Push and open the run. The graph shows the caller's job expanding into the reusable workflow's job.
  4. Add a second caller job passing '3.12', and see both run from the same definition.
  5. Move the setup and install steps into .github/actions/setup/action.yml as a composite action and use it with uses: ./.github/actions/setup.

Commands

# .github/workflows/python-ci.yml
on:
  workflow_call:
    inputs:
      python-version:
        type: string
        default: '3.13'
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-python@v6
        with: { python-version: '${{ inputs.python-version }}' }
      - run: pip install -r requirements-dev.txt && pytest -q

# .github/workflows/caller.yml
on: push
jobs:
  ci:
    uses: ./.github/workflows/python-ci.yml
    with:
      python-version: '3.13'

Watch out for

Cost
Free in public repositories.
Security
Pass only the secrets a reusable workflow needs instead of secrets: inherit, and pin shared workflows from other repositories to a tag or SHA.
Common mistakes
Calling a reusable workflow as a step (it must be a job), and nesting reusable workflows more than the allowed depth.

Clean up

Delete the two workflow files when you've finished, or keep them for the final project.

Words to know

Reusable workflow
A workflow with workflow_call that other workflows run as a job.
Composite action
An action made of several steps, defined in action.yml.
inputs
Typed values a caller passes in.
secrets: inherit
Passes all the caller's secrets to the reusable workflow.

Tick off each step and track your progress in the guide.

Open this task in DevOps, Hands On

Keep going