Interview Prep/CI/CD/GitHub Actions Failures

`if: github.ref == 'refs/heads/main'` never true on PR builds.

BeginnerTroubleshootingGitHub Actions Failures
Answer

Likely causes → On pull_request events github.ref is refs/pull/<n>/merge, not the branch.

Diagnose → Print github.ref, github.head_ref, github.base_ref.

Fix → Use github.head_ref for the PR branch, or condition on github.event_name == 'push'.

Prevent → Dump context once in debugging.

All CI/CD questions

More on GitHub Actions Failures