Restrict production deployment to your protected main branch.

Section: Branching and trigger patterns

Deploy only from main

yaml
yaml
on:
  push:
    branches: [main]
Explanation

Keep deploy workflows tighter than CI workflows. A common split is PR checks for CI and push-to-main for CD.

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 Branching and trigger patterns
Validate pull requests only
Run CI before code reaches main.
OpenIn sheetyamlsame section
Nightly scheduled workflow
Run audits, backups, smoke tests, or dependency checks on a schedule.
OpenIn sheetyamlsame section
Minimal GitHub Actions pipeline
Build and test on pushes and pull requests.
Minimal GitLab CI pipeline
Run install, test, and build using stages.
Minimal Jenkins declarative pipeline
Run checkout, install, test, and build in a Jenkinsfile.