iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

GitHub

GitHub conventions that pay off long after the first PR - branch protection, CODEOWNERS, required checks, and auto-merge.

GitHub - production setup

EXAMPLE
# 1. Branch protection on main
# Settings -> Branches -> Add rule
# - Require pull request reviews before merging (at least 1)
# - Require status checks to pass before merging
# - Require branches to be up to date before merging
# - Require signed commits (optional)
# - Restrict who can push to matching branches (admins only for hotfix)
# - Do not allow force pushes
# - Do not allow deletions

# 2. CODEOWNERS in .github/CODEOWNERS
*                       @yourorg/maintainers
/src/api/               @yourorg/backend
/src/web/               @yourorg/frontend
/.github/               @yourorg/platform
/docs/                  @yourorg/docs

# 3. Pull request template - .github/PULL_REQUEST_TEMPLATE.md
## What
A short description.

## Why
The reason this change is needed.

## How to verify
- [ ] Tests pass
- [ ] Manual smoke check

## Risk
Low / Medium / High and what could break.

# 4. Issue templates - .github/ISSUE_TEMPLATE/
# bug.yml, feature.yml in YAML form fields

# 5. GitHub Actions - .github/workflows/ci.yml
name: CI
on:
  pull_request:
    branches: [main]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: '20', cache: 'npm' }
      - run: npm ci
      - run: npm run lint
      - run: npm test -- --coverage
      - uses: codecov/codecov-action@v4

# 6. Required status checks
# In branch protection: pick the check names that must pass.
# 'CI / test' is the typical name.

# 7. Auto-merge
# Enable 'Allow auto-merge' in repo settings.
# On a PR: select 'Squash and merge' from the dropdown, then 'Enable auto-merge'.
# It will merge when all checks pass and reviews are met.

# 8. Renovate or Dependabot
# .github/dependabot.yml
version: 2
updates:
  - package-ecosystem: npm
    directory: '/'
    schedule: { interval: weekly }
    open-pull-requests-limit: 5

Why it matters

A repo without branch protection, CODEOWNERS, and required checks is one tired engineer away from a bad afternoon. Set the rails once; the rest is just merging.

Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.

Example

Example
# GitHub: PRs, Actions, Issues, Pages, Codespaces.
gh repo create my-app --public
Try it Yourself »

Discussion

Loading…