Guide
Sharing CI/CD Logic with GitHub Actions Reusable Workflows
Learn how to define and call GitHub Actions reusable workflows to share CI/CD steps across repositories, with a concrete example, limits, and pitfalls to avoid.
Published by Tasadduq Burney
04 Sept 2025, 17:56 UTC
2 min118.6K views0

Why use reusable workflows
Reusable workflows let you define a set of jobs once and call them from many repositories, reducing duplication and keeping CI/CD practices consistent.
Example reusable workflow
Create .github/workflows/reusable.yml in the source repository:
name: Reusable CI
on:
workflow_call:
inputs:
build-tool:
description: 'Tool to show version'
required: true
type: string
secrets:
npm-token:
required: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
env:
NPM_TOKEN: ${{ secrets.npm-token }}
- name: Show tool version
run: ${{ inputs.build-tool }} --version
Caller workflow
In any other repository reference the reusable workflow:
name: Caller CI
on:
push:
branches: [ main ]
jobs:
use-reusable:
uses: owner/repo/.github/workflows/reusable.yml@v1
with:
build-tool: 'npm'
secrets:
npm-token: ${{ secrets.NPM_TOKEN }}
Limits
- Reusable workflows cannot access the caller’s repository secrets unless they are explicitly listed in the
secrets:block. - They run with the caller’s
GITHUB_TOKENand inherit its permissions. - Nesting depth is capped at four levels.
- A single workflow run may invoke at most twenty reusable workflows.
Common mistakes
- Omitting the
workflow_calltrigger – the workflow will not be callable. - Declaring an input or secret as required but forgetting to pass it from the caller.
- Using a relative path like
./.github/workflows/reusable.ymlinstead of the fullowner/repo/.github/workflows/file@refsyntax. - Assuming the reusable workflow can push to protected branches without granting
contents: writepermission on the caller’s token.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.