Quick Links
Gitea Webhook Setup
Prerequisites
- • Gitea server access
- • SSH keys configured with Gitea
- • Repository already created in Gitea
Step 1: Get Your Webhook URL
Find your server's IP address:
hostname -I | awk '{print $1}'
Your webhook URL will be: http://YOUR_SERVER_IP:9001/deploy
Step 2: Add Webhook in Gitea
- Navigate to your repository - Go to your Gitea instance and select your repository
- Go to Webhooks settings - Click Settings in the repository menu, then click Webhooks in the left sidebar
- Click "Add Webhook"
Step 3: Configure Webhook Settings
| Target URL: | http://YOUR_SERVER_IP:9001/deploy |
| HTTP Method: | POST |
| Content Type: | application/json |
| Secret: | Leave empty for now |
| Events: | ✅ Push Events |
| Branch Filter: | main |
| Active: | ✅ Yes |
Step 4: Save and Test
- Click Add Webhook
- Click the webhook name to view details
- Click Test Delivery to test
GitHub Webhook Setup
Prerequisites
- • GitHub account
- • SSH keys configured with GitHub
- • Repository already created on GitHub
Step 1: Get Your Webhook URL
Same as Gitea - find your server IP:
hostname -I | awk '{print $1}'
Your webhook URL: http://YOUR_SERVER_IP:9001/deploy
Step 2: Add Webhook in GitHub
- Navigate to your repository - Go to github.com and select your repository
- Go to Webhooks settings - Click Settings tab, then click Webhooks in the left sidebar
- Click "Add webhook"
Step 3: Configure Webhook Settings
| Payload URL: | http://YOUR_SERVER_IP:9001/deploy |
| Content type: | application/json |
| Secret: | Leave empty for now |
| Which events: | Just the push event |
| Active: | ✅ Yes |
Step 4: Save and Test
- Click Add webhook
- GitHub will show you recent deliveries
- Click on a delivery to see details
SSH Setup (Required for Both)
For Gitea:
- Generate SSH key (if you don't have one):
ssh-keygen -t ed25519 -C "your-email@example.com" - Add SSH key to Gitea:
cat ~/.ssh/id_ed25519.pub - Copy the output, go to Gitea → Settings → SSH/GPG Keys
- Click "Add Key" and paste your public key
- Test connection:
ssh -T git@your-gitea-server.com
For GitHub:
- Generate SSH key (if you don't have one):
ssh-keygen -t ed25519 -C "your-email@example.com" - Add SSH key to GitHub:
cat ~/.ssh/id_ed25519.pub - Copy the output, go to GitHub → Settings → SSH and GPG keys
- Click "New SSH key" and paste your public key
- Test connection:
ssh -T git@github.com
Branch Configuration
Determine Your Main Branch
Check your repository's default branch:
git branch -r
Look for origin/main or origin/master
Set Webhook Branch Filter Accordingly
- • If you see
origin/main→ Usemain - • If you see
origin/master→ Usemaster
Update Deploy Script if Needed
Your deploy.sh should match your main branch:
echo "=== PULLING LATEST CHANGES ==="
git pull origin main # or git pull origin master
Testing Your Webhook
Method 1: Push Test
# Make a small change
echo "test" >> test.txt
git add test.txt
git commit -m "Test webhook"
git push origin main
Method 2: Manual Test
curl -X POST http://localhost:9001/deploy \
-H "Content-Type: application/json" \
-d '{
"ref": "refs/heads/main",
"repository": {
"name": "your-repo-name"
}
}'
Method 3: Built-in Test
- • Gitea: Use "Test Delivery" button in webhook settings
- • GitHub: View recent deliveries in webhook settings
Verify Success
Check your webhook server logs:
journalctl -u webhook-multi-repo -f
You should see deployment logs indicating success!
Common Webhook Issues
Issue: "404 Not Found"
Cause: Wrong webhook URL
Fix: Verify your server IP and port 9001 is accessible
Issue: "400 Bad Request"
Cause: Wrong content type
Fix: Ensure "application/json" is selected
Issue: "No deployment triggered"
Cause: Wrong branch filter
Fix: Match webhook branch filter to your actual main branch
Issue: "Git pull failed"
Cause: SSH keys not configured
Fix: Set up SSH keys with your Git provider
Webhook Setup Complete!
Your webhook is now configured and ready to trigger deployments!
- ✅ Webhook server running on port 9001
- ✅ Correct webhook URL configured
- ✅ SSH keys set up with Git provider
- ✅ Branch filter matches your main branch
- ✅ Test push triggers deployment
- ✅ Deployment logs show success