Duplicated workflow blocks

Rule ID

no_reusable_workflow

Category

maintainability

Severity

medium

Identical job definitions appear across multiple workflow files without using reusable workflows (workflow_call trigger).

Detection

heuristic — Structural comparison across multiple jobs or steps.

Examples

Non-compliant:

jobs:
  test-v1:
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - run: npm test
  test-v2:
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - run: npm test

Compliant:

jobs:
  test-v1:
    uses: ./.github/workflows/reusable-test.yml
    with: {node-version: 18}
  test-v2:
    uses: ./.github/workflows/reusable-test.yml
    with: {node-version: 20}

Fix: Extract the shared job definition into a reusable workflow (on: workflow_call:) or a composite action, then call it with uses:.