Ce que vous saurez faire à la fin
- Adopter trunk-based workflow en équipe
- Utiliser PRs et code review efficacement
- Automatiser avec husky + commitlint
- Protéger main correctement
- Releases avec changelog automatique
Étape 1 — Workflow trunk-based
git switch main
git pull --rebase
git switch -c feat/export-pdf
# Dev + commits atomiques
git add src/pdf.ts
git commit -m "feat(pdf): export facture PDF"
git push -u origin feat/export-pdf
gh pr create --fill --base main
Étape 2 — Conventional commits
feat: nouveauté
fix: correctif
docs: doc
refactor: refactor
test: tests
chore: maintenance
perf: performance
feat(auth): login OAuth Google
fix(billing): arrondit TVA au FCFA supérieur
BREAKING CHANGE: renomme /v1/ en /v2/
Étape 3 — Template PR
<!-- .github/pull_request_template.md -->
## Contexte
Closes #
## Changements
-
## Tests
- [ ] Unitaires
- [ ] Testé local
## Rollback
<!-- comment revenir en arrière -->
Étape 4 — Protection de main
gh api -X PUT repos/ORG/REPO/branches/main/protection \
-F required_status_checks='{"strict":true,"contexts":["test"]}' \
-F required_pull_request_reviews='{"required_approving_review_count":1}' \
-F enforce_admins=true
Étape 5 — CODEOWNERS
# .github/CODEOWNERS
* @org/core
/src/billing/ @org/billing
/infra/ @org/sre
*.sql @aminata-diop
Étape 6 — Husky + commitlint
npm install -D husky @commitlint/cli @commitlint/config-conventional lint-staged
npx husky init
echo "npx --no -- commitlint --edit $1" > .husky/commit-msg
echo "npx lint-staged" > .husky/pre-commit
// commitlint.config.js
export default { extends: ["@commitlint/config-conventional"] };
Étape 7 — Code review
gh pr checkout 142
gh pr diff 142 | less
gh pr review 142 --approve --body "LGTM"
gh pr review 142 --request-changes --body "Ajouter tests edge case"
# Merger
gh pr merge 142 --squash --delete-branch
Règles d’équipe : PR ≤ 400 lignes, retour sous 24h, résoudre tous les fils avant merge.
Étape 8 — Résoudre conflits avec rebase
git fetch origin main
git rebase origin/main
# Si conflit:
git status
# éditer fichiers
git add fichier-resolu.js
git rebase --continue
git push --force-with-lease
Étape 9 — Changelog automatique
npm install -D conventional-changelog-cli
npx conventional-changelog -p angular -i CHANGELOG.md -s
git add CHANGELOG.md
git commit -m "chore(release): 1.3.0"
git tag v1.3.0
git push --tags
Étape 10 — Semantic-release en CI
name: Release
on:
push:
branches: [main]
permissions: { contents: write }
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: actions/setup-node@v4
- run: npm ci
- run: npx semantic-release
env: { GITHUB_TOKEN: ${{ github.token }} }
Checklist équipe
✓ Branch protection sur main
✓ CODEOWNERS défini
✓ Template PR
✓ husky + commitlint
✓ lint-staged auto-format
✓ Squash merge
✓ Tags sémantiques
✓ Changelog auto
✓ Review sous 24h