33 / 48 · 16 CI/CD Pipelines · Pipeline Optimization← prev⊞ allnext →☰ Read as one page
5.8Advanced Optimization Techniques
Reusable Workflows
Extract common patterns into reusable workflows to avoid duplication:
# .github/workflows/reusable-test.yml
on:
workflow_call:
inputs:
test-command:
required: true
type: string
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: 'npm'
- run: npm ci
- run: ${{ inputs.test-command }}
Dependency Graph Optimization
If your repository has multiple packages (monorepo), only test packages affected by the change:
# Use a tool like Nx or Turborepo to detect affected packages
- run: npx nx affected --target=test --base=origin/main --head=HEAD