This project is a lightweight webhook listener built in Go that automatically:
- Receives push events from a GitHub repository ✅
- Clones or pulls the latest code from the repo 🧰
- Runs
docker compose up -dto redeploy the application 🐳
Perfect for simple CI/CD deployments without heavy tooling.
- When you push to a GitHub repo,
- GitHub sends a POST request to
http://<your-server>:8080/webhook.
-
If the repo is already cloned in
/app/hello-world:- It runs
git pull.
- It runs
-
If not cloned yet:
- It runs
git clone <repo-url> /app/hello-world.
- It runs
-
Once the code is updated,
-
It executes:
docker compose up -d
inside the repository folder.
.
├── main.go # Webhook listener source code
├── Dockerfile # Container build file
└── README.md # Documentation
docker build -t webhook-listener .docker run -p 8080:8080 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /home/iqbal/hello-world:/app/hello-world \
--name webhook-listener \
webhook-listener-p 8080:8080→ Exposes the webhook listener on port 8080-v /var/run/docker.sock:/var/run/docker.sock→ Allows container to control Docker on the host-v /home/iqbal/hello-world:/app/hello-world→ Persists your app code on the host
If you want GitHub to reach your local machine:
ngrok http 8080Copy the HTTPS forwarding URL from ngrok and use it as your webhook URL.
-
Go to your GitHub repository → Settings → Webhooks.
-
Click “Add webhook”.
-
Set:
- Payload URL:
https://<ngrok-url>/webhook - Content type:
application/json - Select event: “Just the push event”.
- Payload URL:
-
Save the webhook.
✅ Now every push triggers the listener → pulls latest code → redeploys with Docker Compose.
You can also test the webhook endpoint manually with:
curl -X POST http://localhost:8080/webhook \
-H "Content-Type: application/json" \
-d '{"repository": {"clone_url":"https://github.com/your/repo.git","name":"hello-world"}, "ref":"refs/heads/main"}'View logs from the running container:
docker logs -f webhook-listenerIf something goes wrong (e.g., Git clone or Docker compose fails), the error is printed in the logs.
-
Git installed inside the container (already included in the Dockerfile)
-
Docker & Docker Compose installed on the host
-
The container must have access to the host’s Docker socket:
-v /var/run/docker.sock:/var/run/docker.sock
| Component | Purpose |
|---|---|
| Go Web Server | Receives and processes webhooks |
| Git | Clones and pulls repository |
| Docker Compose | Runs application after deployment |
| ngrok (optional) | Exposes local server to GitHub |
docker stop webhook-listener
docker rm webhook-listener- Add support for branch-based deployments (e.g., only
main) - Add authentication or secret token validation
- Add error reporting or Slack notifications
- Add rollback mechanism if deploy fails
✅ You now have a simple auto-deploy system using Go + Git + Docker Compose.