Use expressions with `if` to gate steps.
Section: Jobs, steps, and conditionals
Run a step only on main
yaml
yaml
- name: Publish
if: github.ref == 'refs/heads/main'
run: npm run publishExplanation
Conditionals help keep a single workflow flexible across branches and events.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Jobs, steps, and conditionals