Configurer des webhooks pour le déploiement automatique
9 vues · Mis à jour le 22/05/2026
Webhooks de déploiement
Principe
Un webhook est une URL sur votre serveur que GitHub/GitLab appelle automatiquement à chaque push. Le script exécute un git pull pour mettre à jour le site.
Script de déploiement
<?php\n// deploy.php\n$secret = 'VOTRE_SECRET';\n$signature = $_SERVER['HTTP_X_HUB_SIGNATURE_256'] ?? '';\n$payload = file_get_contents('php://input');\n\nif (hash_equals('sha256=' . hash_hmac('sha256', $payload, $secret), $signature)) {\n shell_exec('cd /home/user/public_html && git pull origin main 2>&1');\n echo 'Deployed!';\n} else {\n http_response_code(403);\n echo 'Invalid signature';\n}Configuration GitHub
- Settings → Webhooks → Add webhook
- URL:
https://votredomaine.ca/deploy.php - Secret: votre secret partagé
- Events: Just the push event
Cet article vous a-t-il été utile?
Articles similaires