The CI/CD Thing provides a REST API for managing deployments and monitoring the system.
Most endpoints require authentication using a Bearer token:
Authorization: Bearer your_api_key_here
The API key is configured via the API_KEY environment variable.
GET /health
Returns the health status and configuration of the service.
Response:
{
"status": "healthy",
"service": "cicd-thing",
"version": "1.0.0",
"uptime_seconds": 123,
"config": {
"port": "3000",
"concurrency_limit": 2,
"timeout_seconds": 300,
"branch_filter": "main",
"dry_run": false,
"repositories": 2,
"config_file_loaded": "/etc/cicd-thing/config.toml"
},
"features": {
"webhook_listener": true,
"manual_deployment": true,
"logs_viewer": true,
"rate_limited_logs": true
}
}GET /status
Returns detailed system status including deployment information.
Response:
{
"service": "cicd-thing",
"status": "running",
"deployments": {
"active": 0,
"queued": 0,
"completed": 0,
"note": "Deployment statistics are currently placeholders - real tracking will be added in a future version"
},
"repositories": {
"octocat/Hello-World": "~/projects/hello-world",
"myorg/api": "~/apps/api"
},
"configuration": {
"concurrency_limit": 2,
"timeout_seconds": 300,
"branch_filter": "main",
"dry_run": false
}
}POST /deploy
Triggers a manual deployment for a specified repository.
Authentication: Required
Query Parameters:
repo(required): Repository full name (e.g., "octocat/Hello-World")branch(optional): Branch to deploy (defaults to configured branch filter)commit(optional): Commit hash to deploy (defaults to "HEAD")
Example Request:
curl -X POST "http://localhost:3000/deploy?repo=octocat/Hello-World&branch=main&commit=abc123" \
-H "Authorization: Bearer your_api_key"Success Response (200):
{
"status": "success",
"message": "Manual deployment triggered",
"repository": "octocat/Hello-World",
"branch": "main",
"commit": "abc123"
}Error Responses:
400 Bad Request:
{
"error": "Missing required parameter: repo"
}401 Unauthorized:
{
"error": "Unauthorized"
}500 Internal Server Error:
{
"error": "Failed to trigger deployment: deployment already in progress for app Hello-World"
}GET /logs
Provides a web-based log viewer interface for monitoring deployment logs and system activity.
Rate Limiting: Limited to 30 requests per minute per IP address
Query Parameters:
limit(optional): Number of log lines to display (10, 20, 50, 100, 200). Defaults to 50.
Example Request:
curl "http://localhost:3000/logs?limit=100"Response: Returns an HTML page with:
- Interactive log viewer with dark theme
- Dropdown to select number of lines (10, 20, 50, 100, 200)
- Refresh button for manual updates
- Auto-refresh every 30 seconds
- Syntax highlighting for different log levels
- Responsive design for mobile and desktop
Features:
- Real-time log monitoring
- Configurable line limits
- Color-coded log levels (ERROR, INFO, SUCCESS, WARNING)
- Timestamp highlighting
- Scrollable log container
- Auto-refresh functionality
Security:
- Respects IP allowlist configuration
- Rate limited to prevent abuse
- Read-only access to log files
POST /admin/webhook (configurable)
Receives GitHub webhook events and triggers deployments automatically.
Headers:
X-Hub-Signature-256: GitHub webhook signatureX-GitHub-Event: Event type (must be "push")Content-Type: application/json
Request Body: GitHub webhook payload (JSON)
Success Response (200):
Deployment triggered successfully
Other Responses:
200: "No deployment triggered" (wrong branch or no mapping)200: "Event type not supported" (non-push events)400: "Failed to parse webhook payload"401: "Invalid signature"405: "Method not allowed"
All API endpoints return appropriate HTTP status codes:
200: Success400: Bad Request (invalid parameters)401: Unauthorized (missing or invalid API key)403: Forbidden (IP not allowed)405: Method Not Allowed500: Internal Server Error
Error responses include a descriptive message:
{
"error": "Description of the error"
}Rate limiting is implemented for the /logs endpoint to ensure optimal performance:
- Limit: 30 requests per minute per IP address
- Response code: 429 Too Many Requests (when limit exceeded)
- Error message: "Rate limit exceeded. Please wait before making more requests."
This rate limit is designed to allow normal human viewing of logs while preventing abuse.
Note: Built-in IP allowlisting has been removed. Restrict access using your reverse proxy, firewall, or WAF instead.
curl http://localhost:3000/healthcurl -X POST "http://localhost:3000/deploy?repo=myorg/myapp" \
-H "Authorization: Bearer your_api_key"curl http://localhost:3000/status- Go to your repository settings
- Navigate to "Webhooks"
- Click "Add webhook"
- Set Payload URL:
http://your-server:3000/webhook - Set Content type:
application/json - Set Secret: Your webhook secret
- Select "Just the push event"
- Ensure "Active" is checked
- Click "Add webhook"
- Always use HTTPS in production
- Keep API keys secure and rotate them regularly
- Use external network controls (reverse proxy, firewall, WAF) to restrict access
- Monitor logs for suspicious activity
- Use strong webhook secrets (at least 20 characters)
The health and status endpoints can be integrated with monitoring systems:
- Prometheus: Scrape
/healthendpoint - Nagios: Monitor
/healthfor status changes - Custom monitoring: Parse JSON responses for alerts alerts