Instructions de Déploiement GitLab - Protection Branche Main
🚀 Configuration GitLab réalisée
Repository configuré :
- GitLab privé :
git@git.pa4.rdem-systems.com:rdem-systems/pkiaas.git - GitHub public :
git@github.com:rdemongeot/pkiaas.git - Synchronisation : Push automatique sur les deux remotes
Fichiers de configuration créés :
.gitlab-ci.yml- Pipeline CI/CD complète.gitlab/CODEOWNERS- Review automatique requise.gitlab/merge_request_templates/Default.md- Template MR structurédocs/gitlab-branch-protection.md- Guide complet
🛡️ Configuration Protection Branche Main (À DEPLOYER PLUS TARD)
Dans GitLab UI : Settings > Repository > Protected branches
Branch: main
Allowed to push: No one
Allowed to merge: Maintainers only
Allowed to force push: No one
Code owner approval required: Yes
Settings > General > Merge requests
Pipelines must succeed: ✓ Enabled
All discussions must be resolved: ✓ Enabled
Prevent approvals by author: ✓ Enabled
Prevent approvals by committers: ✓ Enabled
Required approvals: 1 minimum
Settings > General > Merge request approvals
Merge request approval is required: ✓ Enabled
Require approval from code owners: ✓ Enabled
Prevent approval by merge request author: ✓ Enabled
📋 Checklist de déploiement (quand ready)
Phase 1 : Protections de base
- [ ] Activer "Protected branches" sur main
- [ ] Interdire push direct : "Allowed to push: No one"
- [ ] Autoriser merge : "Allowed to merge: Maintainers"
- [ ] Désactiver force push
Phase 2 : Quality gates
- [ ] Activer "Pipelines must succeed"
- [ ] Activer "All discussions must be resolved"
- [ ] Configurer "Required approvals: 1"
Phase 3 : Code owners
- [ ] Activer "Require approval from code owners"
- [ ] Vérifier fichier
.gitlab/CODEOWNERSactif - [ ] Tester avec une MR de test
Phase 4 : Notifications
- [ ] Configurer intégrations Slack/Teams (optionnel)
- [ ] Configurer notifications email
- [ ] Tester workflow complet
🔧 Commandes pour activer les protections
Via GitLab CLI (si installé)
# Installer GitLab CLI
curl -s https://raw.githubusercontent.com/glab-cli/glab/main/install.sh | sudo sh
# Se connecter
glab auth login --hostname git.pa4.rdem-systems.com
# Protéger la branche main
glab api projects/:id/protected_branches -d '{
"name": "main",
"push_access_level": 0,
"merge_access_level": 40,
"allow_force_push": false
}'
Via Interface Web
- Aller sur :
https://git.pa4.rdem-systems.com/rdem-systems/pkiaas - Settings > Repository > Protected branches
- Sélectionner "main" et configurer selon checklist ci-dessus
🚦 Workflow sécurisé (une fois activé)
Développement normal
# 1. Créer feature branch
git checkout -b feature/nom-fonctionnalite
# 2. Développer
git add .
git commit -m "feat: nouvelle fonctionnalité"
# 3. Pousser
git push gitlab feature/nom-fonctionnalite
# 4. Créer MR via GitLab UI
# 5. Attendre approval + pipeline success
# 6. Merge par maintainer
Urgence/Hotfix
# 1. Créer hotfix branch
git checkout -b hotfix/fix-critique
# 2. Fix rapide
git add .
git commit -m "fix: correction critique"
# 3. MR prioritaire
git push gitlab hotfix/fix-critique
# Marquer MR comme "Critical" pour review express
📊 Surveillance recommandée
Métriques à monitorer
- Temps de résolution des MR
- Taux de success pipeline
- Violations sécurité détectées
- Tentatives de push direct bloquées
Outils GitLab
- Analytics > Repository : Contribution stats
- Analytics > CI/CD : Pipeline performance
- Security & Compliance : Vulnerability reports
- Settings > Integrations : Notifications
⚠️ Notes importantes
Pendant phase rush-dev (ACTUEL)
- ✅ Push direct sur main autorisé
- ✅ Pas de review obligatoire
- ✅ Pipeline CI/CD active mais non-bloquante
- ✅ Tests automatiques en cours
Après rush-dev (DEPLOYER PLUS TARD)
- ❌ Push direct sur main bloqué
- ✅ MR + approval obligatoires
- ✅ Pipeline success requise pour merge
- ✅ Code owners review automatique
🆘 Emergency Override
En cas d'urgence absolue (maintainers uniquement)
- Temporairement désactiver protections
- Push direct autorisé
- OBLIGATOIRE : Réactiver immédiatement après
- OBLIGATOIRE : Post-mortem issue
Commande d'urgence
# Désactiver temporairement (GitLab CLI)
glab api projects/:id/protected_branches/main -X DELETE
# Push d'urgence
git push gitlab main
# Réactiver immédiatement
glab api projects/:id/protected_branches -d '{
"name": "main",
"push_access_level": 0,
"merge_access_level": 40
}'
📞 Support
Contacts
- Maintainer principal : @rdem
- GitLab admin : RDEM Systems
- Documentation :
/docs/gitlab-branch-protection.md
Ressources
- Guide complet :
docs/gitlab-branch-protection.md - Template MR :
.gitlab/merge_request_templates/Default.md - Code owners :
.gitlab/CODEOWNERS - Pipeline :
.gitlab-ci.yml
Status actuel : Configuration prête, déploiement différé pour phase post-rush-dev
Vous n'avez pas envie de la manager ?
Découvrir notre offre PKI As A Service