Reducing CI/CD Duplication with GitHub Actions Composite Actions
Learn how to create and use GitHub Actions composite actions to eliminate duplicated CI steps, improve maintainability, and version shared workflow logic across repositories.
09 Mar 2026, 05:55 UTC

The problem: repeated CI steps across repositories
Many microservices share the same build steps—installing dependencies, running lint, executing tests. Copy‑pasting these blocks into each repository’s workflow leads to drift, makes updates tedious, and obscures the true CI process.
What is a composite action?
A composite action bundles multiple steps into a single, reusable unit defined in an action.yml file. It can consume inputs, run shell commands, and call other actions, all while being versioned like any other repository.
Creating a reusable composite action
# .github/actions/node-ci/action.yml
name: 'Node CI'
description: 'Install dependencies and run tests for a Node.js project'
inputs:
node-version:
description: 'Version of Node to use'
required: true
default: '18'
runs:
using: 'composite'
steps:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
Consuming the action in a workflow
# .github/workflows/ci.yml
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: myorg/node-ci@v1
with:
node-version: '20'
Trade‑offs and debugging tips
- Composite actions hide the matrix; define
strategyin the calling workflow if you need parallel jobs. - Logs appear under a single step named after the action call, making it harder to see which sub‑step failed. You can add explicit
namefields inside the composite to retain granularity. - Over‑abstracting can hide details; keep the action focused on a single concern (e.g., Node setup) rather than a full pipeline.
How to verify it works
- Push a commit to a repository that uses the composite action.
- Go to the Actions tab, open the latest workflow run.
- Expand the step that calls
myorg/node-ci@v1and check the logs forSetup Node,Install dependencies, andRun tests. - Change the
node-versioninput and re‑run; the setup step should reflect the new version.
If the logs show the expected commands and the workflow concludes with success, the composite action is correctly versioned and reusable.
Takeaway
By extracting repeated steps into a composite action stored in its own repository, you eliminate copy‑paste, gain a single source of truth, and keep workflow files readable. Start small, version the action with tags, and gradually replace duplicated blocks across your microservices.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.