Webhooks
Webhooks allow you to notify external systems whenever an event occurs in your OpenCodeHub repositories.
Supported Events
Section titled “Supported Events”push: Triggered when code is pushed.pull_request: Triggered on PR open, close, reopen, merge.issue: Triggered on issue creation or updates.
configuration
Section titled “configuration”- Navigate to Repository Settings > Webhooks.
- Click Add Webhook.
- Payload URL: The external URL to send the POST request to.
- Content Type:
application/json(recommended) orapplication/x-www-form-urlencoded. - Secret: detailed shared secret to sign payload (HMAC SHA-256).
- Events: Select “Just the push event” or “Send me everything”.
Verifying Signatures
Section titled “Verifying Signatures”OpenCodeHub sends a X-Hub-Signature-256 header. You should verify this in your consumer code to ensure the request came from OpenCodeHub.
Node.js Example:
const crypto = require('crypto');
function verifySignature(payload, signature, secret) { const hmac = crypto.createHmac('sha256', secret); const digest = 'sha256=' + hmac.update(payload).digest('hex'); return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(digest));}Debugging
Section titled “Debugging”You can view the “Recent Deliveries” list in the Webhook settings page to see:
- Request headers and payload.
- Response status code and body.
- Delivery duration.