Interview Prep/Git & GitHub/Branch protection, rulesets, CODEOWNERS and review at scale

Why require status checks by job name and what is a common pitfall?

BeginnerProductionBranch protection, rulesets, CODEOWNERS and review at scale
Answer

The required check is matched by name. If a workflow is skipped through path filters, the required check stays pending forever and blocks the PR. Fix by having an always-running aggregate job (ci-ok) as the single required check, with needs: on the real jobs and if: always() logic.

ci-ok:
  needs: [build, test, lint]
  if: always()
  runs-on: ubuntu-latest
  steps:
    - run: test "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" = "false"
All Git & GitHub questions Roadmap: Git & GitHub

More on Branch protection, rulesets, CODEOWNERS and review at scale