CI/CD on GitHub

7

questions

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.

How do you roll back a bad release?

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.

How do you store deploy keys?

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.

How is your deploy set up?

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.

What does a GitHub Actions workflow consist of?

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.

Which checks do you run on PRs?

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.

Which triggers have you used?

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.