Continuous Deployment: Auto-Deploying to VPS via GitHub Webhooks
Trigger automatic git pulls, builds, and graceful process restarts upon every repository push.
In brief
- Automate manual deployment steps using GitHub Webhooks on every push.
- Bind your listener to the SERVER_IP variable, not 127.0.0.1.
- Always verify the webhook secret to prevent unauthorized deployments.
What you need
- A GitHub repository you administer
- A deploy key or token on the server with access to the repo
- A publicly reachable port to receive the webhook
On this page
Discord Bots guides
Eliminate repetitive manual SSH logins for git pull and service restarts. GitHub Webhooks notify your server on every commit push, triggering automated deployment workflows.
1. Lightweight Webhook Receiver#
const http = require('http');
const { exec } = require('child_process');
http.createServer((req, res) => {
if (req.method === 'POST' && req.url === '/webhook/deploy') {
console.log('GitHub Push algilandi. Dagitim baslatiliyor...');
exec('sh deploy.sh', (err, stdout) => {
if (err) console.error(err);
console.log(stdout);
});
res.writeHead(200);
return res.end('OK');
}
res.writeHead(404);
res.end();
}).listen(4000);How to Implement This?
Clodo Control Panel Quick Method
Your own webhook listenerThere is no built-in GitHub integration in the panel; you set up auto-deploy yourself with the webhook listener from this guide. What the panel provides is the runtime for that listener and a publicly reachable port.
Step-by-step Execution:
- 1Pick Node.js or Python on the 'Runtime' tab; the listener runs there.
- 2Take the IP and port from the address card and enter it in the repository's Webhooks settings on GitHub.
- 3Bind the listener to SERVER_IP and SERVER_PORT; if it listens on 127.0.0.1, GitHub cannot reach it.
- 4Always verify the webhook secret, or anyone who learns the URL can trigger a deploy.
Frequently Asked Questions
Why is my webhook listener not receiving requests from GitHub?
If your listener is only bound to 127.0.0.1, outside traffic cannot reach it. Make sure it binds to your public IP or the SERVER_IP environment variable and to the port assigned in the panel.
Why is webhook secret verification essential?
Without verification, anyone who knows or discovers your webhook URL can send forged requests and trigger your deployment script. You should always validate GitHub's signature header against your secret key.
What should I do if I encounter a permission error while running deploy.sh?
Ensure the script file has executable permissions. You can grant execution rights by running chmod +x deploy.sh in the terminal.
Can I trigger deployments only on pushes to a specific branch?
Yes. You can inspect the ref property in the incoming JSON payload to check if the push belongs to refs/heads/main and trigger the script only for that branch.
Was this guide helpful?
Feedback goes straight to the team that maintains this guide.
Could not find a solution?
You can open a request with our support team from the panel.

