Deployment Tracking
Record CI/CD deployments via webhook and visualize deployment history in the Laravel Pulse dashboard.
Overview
Section titled “Overview”The deployment tracking system provides:
- Webhook endpoint for CI/CD pipelines to record deployments
- Bearer token authentication for secure webhook access
- Pulse dashboard card showing deployment history
- Environment-aware display with color-coded badges
Architecture
Section titled “Architecture”GitHub Actions --> POST /api/deployments --> DeploymentController | v DeploymentCompleted (Event) | v DeploymentsRecorder (Pulse) | v Pulse Dashboard CardAPI Endpoint
Section titled “API Endpoint”POST /api/deployments
Section titled “POST /api/deployments”Record a deployment.
Authentication: Bearer token via Authorization header
Rate limit: 10 requests per minute
Request:
{ "environment": "production", "version": "v1.2.3", "commit": "abc123def456", "build_date": "2025-01-15T10:30:00Z", "build_id": "12345"}| Field | Type | Required | Constraints |
|---|---|---|---|
| environment | string | Yes | Max 50 chars |
| version | string | Yes | Max 100 chars |
| commit | string | Yes | Max 40 chars (SHA) |
| build_date | string | Yes | ISO 8601 date |
| build_id | string | No | Max 50 chars |
Response (201 Created):
{ "status": "recorded"}Error Responses:
| Status | Description |
|---|---|
| 401 Unauthorized | Invalid or missing bearer token |
| 422 Unprocessable Entity | Validation failed |
| 429 Too Many Requests | Rate limit exceeded |
| 500 Internal Server Error | Token not configured on server |
Source: backend/app/Http/Controllers/Api/DeploymentController.php
Configuration
Section titled “Configuration”Environment Variables
Section titled “Environment Variables”# Required: Secret token for webhook authenticationDEPLOYMENT_API_TOKEN=your-secure-random-tokenGenerate a secure token:
openssl rand -hex 32Config Files
Section titled “Config Files”services.php:
'deployment' => [ 'token' => env('DEPLOYMENT_API_TOKEN'),],pulse.php:
'recorders' => [ \App\Pulse\Recorders\DeploymentsRecorder::class => [], // ... other recorders],Pulse Dashboard Card
Section titled “Pulse Dashboard Card”The Deployments card displays:
- Environment (color-coded badge)
- Version and commit SHA
- Relative timestamp
- Deployment count
Environment Colors
Section titled “Environment Colors”| Environment | Color |
|---|---|
| production | Green |
| staging | Yellow |
| Other | Blue |
Viewing Deployments
Section titled “Viewing Deployments”Navigate to /pulse (requires authentication).
The card:
- Shows last 20 deployments
- Polls for updates every 5 seconds
- Respects selected time period filter
Source: backend/app/Livewire/Pulse/Deployments.php
CI/CD Integration
Section titled “CI/CD Integration”GitHub Actions Example
Section titled “GitHub Actions Example”name: Deploy
on: push: branches: [master]
jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
# ... deployment steps ...
- name: Record deployment if: success() run: | curl -X POST "${{ secrets.API_URL }}/api/deployments" \ -H "Authorization: Bearer ${{ secrets.DEPLOYMENT_API_TOKEN }}" \ -H "Content-Type: application/json" \ -d '{ "environment": "production", "version": "${{ github.ref_name }}", "commit": "${{ github.sha }}", "build_date": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'", "build_id": "${{ github.run_id }}" }'Required GitHub Secrets
Section titled “Required GitHub Secrets”| Secret | Description |
|---|---|
| API_URL | Base URL (e.g., https://api.volare.com) |
| DEPLOYMENT_API_TOKEN | Same token as DEPLOYMENT_API_TOKEN env var |
Security
Section titled “Security”Bearer Token Authentication
Section titled “Bearer Token Authentication”The middleware uses timing-safe comparison to prevent timing attacks:
// ValidateDeploymentToken middlewareif (!hash_equals($expectedToken, $token)) { return new JsonResponse(['error' => 'Unauthorized'], 401);}Best Practices
Section titled “Best Practices”- Use a strong, random token (32+ characters)
- Rotate tokens periodically
- Store tokens in secret managers (GitHub Secrets, AWS Secrets Manager)
- Never commit tokens to version control
- Monitor for failed authentication attempts
Troubleshooting
Section titled “Troubleshooting”401 Unauthorized
Section titled “401 Unauthorized”- Verify token matches between CI/CD and server
- Check
Authorization: Bearer <token>header format - Ensure no whitespace in token
500 Internal Server Error
Section titled “500 Internal Server Error”- Check
DEPLOYMENT_API_TOKENis set in.env - Run
php artisan config:clear - Verify
config/services.phpincludes deployment config
Deployments Not Appearing in Pulse
Section titled “Deployments Not Appearing in Pulse”- Check Pulse is enabled:
PULSE_ENABLED=true - Verify recorder is registered in
config/pulse.php - Check database for
pulse_entriestable - Clear Pulse cache:
php artisan pulse:clear
Related Documentation
Section titled “Related Documentation”- Health Monitoring - Application health and Pulse overview
- Source:
backend/app/Pulse/Recorders/DeploymentsRecorder.php - Source:
backend/app/Http/Middleware/ValidateDeploymentToken.php