Interview Prep/Real-World Interview/Write-a-pipeline tasks

Write a workflow that only runs the backend job when files under `backend/` change.

IntermediateHands-onWrite-a-pipeline tasks
Answer
on:
  pull_request:
jobs:
  changes:
    runs-on: ubuntu-latest
    outputs:
      backend: ${{ steps.filter.outputs.backend }}
    steps:
      - uses: actions/checkout@v4
      - id: filter
        uses: dorny/paths-filter@v3
        with:
          filters: |
            backend:
              - 'backend/**'
  backend:
    needs: changes
    if: needs.changes.outputs.backend == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: make -C backend test

Key trick → The trigger-level paths: filter skips the whole workflow, which leaves required status checks pending forever. A job-level filter lets a skipped job report success.

All Real-World Interview questions Roadmap: Interview readiness

More on Write-a-pipeline tasks