How do you protect main from direct pushes?
A branch protection rule (or ruleset) for main: Require a pull request before merging, a required approval, Require status checks to pass, no force pushes. If needed, the rule applies to admins too.
questions
A branch protection rule (or ruleset) for main: Require a pull request before merging, a required approval, Require status checks to pass, no force pushes. If needed, the rule applies to admins too.
Quickly — by redeploying the previous tag: re-running the workflow for the old release or switching to the previous release on the server. Then the fix: git revert in main and a new patch release.
In GitHub Secrets — at the repository or Environment level (production with its own secrets and rules). In the workflow — via ${{ secrets.NAME }}; values are masked in logs. Never in code or in a committed .env; for deploys — a separate SSH key with minimal permissions.
A merge into main deploys to staging automatically. An annotated v* tag starts a workflow with environment: production that waits for manual approval, builds the artifact and ships it to the server. After the deploy — a smoke test.
A YAML file in .github/workflows/ with triggers (on) and one or more jobs. Each job runs on its own runner (runs-on) and consists of steps: commands (run) or ready-made actions (uses). Jobs run in parallel by default; dependencies are set with needs.
For a WordPress project: PHPCS with WordPress Coding Standards, PHPUnit, ESLint and Stylelint for the frontend, the build (npm run build), and PHPStan and multiple PHP versions when needed. All of them are required status checks.
pull_request — checks on every PR; push to main — deploy to staging; push of v* tags — release; workflow_dispatch — manual run; schedule — nightly jobs on cron.
No questions found. Try another search.