GitHub Webhooks and Integrations: Push Model

GitHub Webhooks and Integrations: Push Model
1. Poll vs. Push: The Webhook Philosophy
- Polling (Bad): Your server asks GitHub every 60 seconds: "Has anything happened yet?" This is slow and eats your internet bandwidth.
- Push (Webhook): GitHub says: "I'll call you when something happens." This is instant, efficient, and how 99% of the web works in 2026.
2. Setting Up a Webhook
- URL: The "Destination" where the message should go (e.g., your Slack Webhook URL).
- Secret: A "Passphrase" that only you and GitHub know. This ensures that a hacker can't "Fake" a message to your server.
- Events: Choose ONLY the events you care about (e.g.,
pushandissue_opened). Don't send everything, or your server will be overwhelmed by "Noise."
3. Communication: Slack and Discord
GitHub has pre-built apps for the world's most popular chat tools.
- Slack: Get a beautiful notification with the commit message and the developer's name. You can even "Deploy" directly from Slack.
- Discord: Perfect for open-source communities who want to see real-time activity in a dedicated
#dev-updateschannel.
4. Building Your Own Handler
If you need something custom (e.g., "When a user opens an issue, automatically create a ticket in our billing system"), you need a custom server.
- The Payload: GitHub sends a JSON Object.
- The Logic: Your Java/Python server receives the JSON, checks the "Secret Signature," and then performs your custom logic. This is the ultimate "No-Limits" automation for advanced engineering teams.
Frequently Asked Questions
Are webhooks secure? Yes, but only if you use a Secret. GitHub uses that secret to "Sign" the message. Your server should calculate its own signature and match it. If they don't match, you should reject the message as a security threat.
What happens if my server is down? GitHub has a Retry system. It will try to send the message again after a few minutes. You can also see a "Recent Deliveries" log in your GitHub settings to manually "Redeliver" any message that failed.
Key Takeaway
Webhooks are the "Vocal Chords" of GitHub. By mastering the push model and the security of the secret signature, you transform your repository into a central hub that coordinates your chat apps, your deployment servers, and your custom business logic in real-time.
Read next: Securing GitHub Secrets and Environments →
Part of the GitHub Mastery Course — engineering the push.
