# ๐Ÿ”— Webhook Setup Guide ## โœ… Webhook Status - **Endpoint**: `https://api.argeict.net/webhook/deploy` - **Method**: POST - **Status**: โœ… Working - **Last Test**: 2026-01-10 12:39:04 UTC --- ## ๐Ÿ“ Gitea Webhook Configuration ### Step 1: Access Gitea Repository Settings 1. Go to: https://gitea.argeict.net/hostadmin/hosting-platform 2. Click on **Settings** (top right) 3. Click on **Webhooks** in the left sidebar ### Step 2: Add New Webhook 1. Click **Add Webhook** button 2. Select **Gitea** from the dropdown ### Step 3: Configure Webhook Fill in the following details: ``` Target URL: https://api.argeict.net/webhook/deploy HTTP Method: POST POST Content Type: application/json Secret: (leave empty for now) ``` **Trigger On:** - โœ… Push events (checked) - Branch filter: `main` **Active:** - โœ… Active (checked) ### Step 4: Save and Test 1. Click **Add Webhook** button 2. The webhook will appear in the list 3. Click on the webhook to view details 4. Click **Test Delivery** button 5. Check the response - should see: ```json { "status": "success", "message": "Deployment triggered successfully", "repository": "hosting-platform", "pusher": "hostadmin", "timestamp": "2026-01-10T12:39:04.822854", "note": "Check /var/log/auto-deploy.log for deployment progress" } ``` --- ## ๐Ÿงช Manual Testing Test the webhook manually with curl: ```bash curl -X POST https://api.argeict.net/webhook/deploy \ -H "Content-Type: application/json" \ -d '{ "repository": { "name": "hosting-platform" }, "pusher": { "username": "test-user" } }' ``` Expected response (HTTP 202): ```json { "status": "success", "message": "Deployment triggered successfully", "repository": "hosting-platform", "pusher": "test-user", "timestamp": "2026-01-10T12:39:04.822854", "note": "Check /var/log/auto-deploy.log for deployment progress" } ``` --- ## ๐Ÿ“Š How It Works ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Developer โ”‚ โ”‚ git push โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Gitea Server โ”‚ โ”‚ (detects push) โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ POST /webhook/deploy โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Backend API โ”‚ โ”‚ (receives webhook) โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ Triggers async โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ deploy-local.sh โ”‚ โ”‚ 1. git pull โ”‚ โ”‚ 2. install dependencies โ”‚ โ”‚ 3. database migration โ”‚ โ”‚ 4. build frontend โ”‚ โ”‚ 5. restart services โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Deployment โ”‚ โ”‚ Complete! โœ… โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` --- ## ๐Ÿ” Monitoring Deployments ### View Deployment Logs ```bash # Real-time deployment logs ssh root@176.96.129.77 'tail -f /var/log/auto-deploy.log' # Last 50 lines ssh root@176.96.129.77 'tail -50 /var/log/auto-deploy.log' ``` ### View Backend Logs ```bash ssh root@176.96.129.77 'tail -f /var/log/hosting-backend.log' ``` ### Check Service Status ```bash ssh root@176.96.129.77 'supervisorctl status' ``` --- ## ๐Ÿ› ๏ธ Troubleshooting ### Webhook Returns Error 1. Check backend logs: ```bash ssh root@176.96.129.77 'tail -100 /var/log/hosting-backend.log' ``` 2. Verify deployment script exists: ```bash ssh root@176.96.129.77 'ls -la /opt/hosting-platform/deploy-local.sh' ``` 3. Test deployment script manually: ```bash ssh root@176.96.129.77 '/opt/hosting-platform/deploy-local.sh' ``` ### Deployment Fails 1. Check deployment logs: ```bash ssh root@176.96.129.77 'cat /var/log/auto-deploy.log' ``` 2. Check for git issues: ```bash ssh root@176.96.129.77 'cd /opt/hosting-platform && git status' ``` 3. Restart services manually: ```bash ssh root@176.96.129.77 'supervisorctl restart hosting-backend hosting-frontend' ``` --- ## ๐Ÿ” Security (Optional) To add webhook secret validation: 1. Generate a secret: ```bash openssl rand -hex 32 ``` 2. Add to Gitea webhook configuration (Secret field) 3. Update backend code to validate the secret --- ## โœ… Verification Checklist - [ ] Webhook added in Gitea - [ ] Test Delivery successful (green checkmark) - [ ] Push to main branch triggers deployment - [ ] Deployment logs show successful completion - [ ] Services restart automatically - [ ] Frontend and backend updated --- **Last Updated**: 2026-01-10 **Maintained By**: Hosting Platform Team