KBDéveloppement

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

  1. Settings → Webhooks → Add webhook
  2. URL: https://votredomaine.ca/deploy.php
  3. Secret: votre secret partagé
  4. Events: Just the push event
Cet article vous a-t-il été utile?
Besoin d'aide?

Vous n'avez pas trouvé votre réponse?

Ouvrir un ticket
Écosystème NHC : 🌐 NHC Hosting 🚀 NHC Portal 🖥️ NHC Panel 🔑 NHC Manager 📡 NHC Uptime 🛡️ NHC Security