Webhooks allow you to build integrations that respond to events in your gityar repositories. When an event occurs (like a push or issue creation), gityar sends an HTTP POST payload to a configured URL.
push - Git push to repositorycreate - Branch or tag createddelete - Branch or tag deletedfork - Repository forkedrelease - Release publishedissues - Issue opened, closed, reopenedissue_comment - Comment on issuepull_request - PR opened, closed, merged, synchronizedwiki - Wiki page created, edited, deletedURL: The endpoint that will receive webhook payloads
https://your-server.com/webhook
Content Type: Format of the payload
application/json - JSON format (recommended)application/x-www-form-urlencoded - Form encodedSecret: Optional secret for payload verification
Your server should verify the X-Gitea-Signature header using HMAC-SHA256.
SSL Verification: Verify SSL certificates
HTTP Basic Auth: Add authentication
username:password
Which events?:
Active: Enable or disable webhook
{
"secret": "your-secret",
"ref": "refs/heads/main",
"before": "6113c5d64f9c8b4e7f2e4a7b3d1c9e5f8a2b4c6d",
"after": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0",
"commits": [
{
"id": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0",
"message": "Add new feature",
"url": "http://localhost:3000/user/repo/commit/a1b2c3d4",
"author": {
"name": "John Doe",
"email": "john@example.com"
}
}
],
"repository": {
"id": 1,
"name": "my-repo",
"full_name": "user/my-repo",
"url": "http://localhost:3000/user/my-repo"
},
"pusher": {
"name": "user",
"email": "user@example.com"
}
}
Always verify webhook signatures:
import hmac
import hashlib
def verify_webhook(payload, signature, secret):
expected = hmac.new(
secret.encode('utf-8'),
payload,
hashlib.sha256
).hexdigest()
return hmac.compare_digest(expected, signature)
Trigger builds on push:
from flask import Flask, request
import subprocess
app = Flask(__name__)
@app.route('/webhook', methods=['POST'])
def webhook():
# Verify signature
# Process payload
# Trigger build
subprocess.run(['./build.sh'])
return 'OK', 200
if __name__ == '__main__':
app.run(port=5000)
Send messages to Slack channel:
import requests
def notify_slack(message):
url = "https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK"
payload = {
"text": f"New push to repository: {message}"
}
requests.post(url, json=payload)
Create tickets in external systems:
def create_jira_issue(payload):
# Extract issue information
# Create ticket in Jira
# Link back to gityar
pass
Webhook not firing:
404 Error:
401/403 Error:
500 Error: