When scripts can restart services across hundreds of servers, a second pair of eyes is cheap insurance. Pull requests (PRs) give you that review – and branch protection makes sure nobody skips it, not even in a hurry.
What a good pull request looks like
- Small – one change, ideally under a few hundred lines. Big PRs get skimmed, not reviewed.
- A clear title – “Disk report: warn at 20% instead of 15%”, not “updates”.
- A description that answers:
- What changes and why?
- How was it tested (which server, what output)?
- What’s the risk, and how do we roll back?
- Linked ticket if your team uses them.
Add a template so every PR asks these questions. Create .github/pull_request_template.md:
## What and why
## How I tested it
- [ ] Ran with -WhatIf / in check mode
- [ ] Ran on a test server
## Risk and rollback
Reviewing a PR
A useful review checklist for automation code:
- Safety – could this hit more servers than intended? Is there a dry-run mode?
- Secrets – any password, token, IP or real hostname that shouldn’t be there?
- Error handling – what happens if one server is offline?
- Readability – would someone on-call at 3 a.m. understand it?
- Tests and checks – did the pipeline pass?
Comment on specific lines, explain why, and suggest a fix. Approve when it’s good enough to be safe – not when it’s how you would have written it.
Protect main
On GitHub: Settings → Branches → Add branch protection rule (or Rulesets) for main:
- ✅ Require a pull request before merging
- ✅ Require approvals – at least 1
- ✅ Dismiss stale approvals when new commits are pushed
- ✅ Require status checks to pass – e.g. your Jenkins or GitHub Actions lint/test job
- ✅ Require conversation resolution
- ✅ Do not allow bypassing the above settings (include administrators)
- ❌ Allow force pushes – leave off
Now main only changes through reviewed, tested PRs.
CODEOWNERS – the right reviewers automatically
Create .github/CODEOWNERS:
# Path Owners
/ansible/ @your-org/windows-automation
/jenkins/ @your-org/ci-admins
/scripts/patching/ @your-org/patching-leads
Combined with Require review from Code Owners, a change to patching scripts can’t merge without the patching leads approving.
Merge strategies
GitHub offers three buttons:
- Merge commit – keeps every commit plus a merge commit
- Squash and merge – one tidy commit per PR (popular for ops repos)
- Rebase and merge – commits added in a straight line
Pick one for the repo and stick with it.
FAQ
We’re a team of two – is this overkill? Branch protection and one required approval cost almost nothing and prevent the “quick fix straight to main” that breaks production on a Friday evening.
Who approves my PR if I’m on my own? Still use PRs and required checks – the automated lint and tests are your reviewer.
What’s next
Next: Repo layout and secrets hygiene for ops teams.
Practise this topic
Test yourself with free questions on this topic – instant answers and explanations.
Start practice questionsGitGitHubPull RequestsCode ReviewIntermediate