feat: implement real uptime monitoring, alerts, admin dashboard, billing & usage tracking
- Uptime service: real HTTP HEAD checks with response time tracking - Alert engine: evaluates scan results, auto-resolves recovered alerts - Notifications: Resend email + webhook delivery - Admin dashboard: system stats, user CRUD, org management (role-protected) - Billing: tier limits (free/starter/pro/enterprise), usage tracking API - Competitor analysis: real Lighthouse comparison + response time - Tests: 11 backend + 11 frontend = 22 total tests passing - Database: added competitor_metrics, alert_configurations tables Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+47
-16
@@ -1,36 +1,67 @@
|
||||
name: Lighthouse Scan Cron Job
|
||||
name: Lighthouse Scan & Uptime Cron
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 */6 * * *' # Every 6 hours
|
||||
workflow_dispatch: # Allow manual triggering
|
||||
- cron: '0 */6 * * *' # Lighthouse scans every 6 hours
|
||||
- cron: '*/5 * * * *' # Uptime checks every 5 minutes
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
mode:
|
||||
description: 'Job to run'
|
||||
required: true
|
||||
default: 'all'
|
||||
type: choice
|
||||
options:
|
||||
- all
|
||||
- scan
|
||||
- uptime
|
||||
|
||||
jobs:
|
||||
scan:
|
||||
uptime:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.schedule == '*/5 * * * *' || github.event.inputs.mode == 'uptime' || github.event.inputs.mode == 'all'
|
||||
steps:
|
||||
- name: Trigger Scan
|
||||
- name: Run Uptime Checks
|
||||
run: |
|
||||
# Get the deployment URL from environment or use a default
|
||||
DEPLOYMENT_URL="${DEPLOYMENT_URL:-https://your-domain.com}"
|
||||
echo "Running uptime checks at: $DEPLOYMENT_URL/api/cron/uptime"
|
||||
|
||||
echo "Triggering scan at: $DEPLOYMENT_URL/api/cron/scan?mode=all"
|
||||
|
||||
# Make the API call
|
||||
response=$(curl -s -w "\n%{http_code}" -X POST "$DEPLOYMENT_URL/api/cron/scan?mode=all")
|
||||
|
||||
# Extract response body and status code
|
||||
response=$(curl -s -w "\n%{http_code}" "$DEPLOYMENT_URL/api/cron/uptime")
|
||||
http_code=$(echo "$response" | tail -n1)
|
||||
response_body=$(echo "$response" | head -n -1)
|
||||
|
||||
echo "Response Status: $http_code"
|
||||
echo "Response Body: $response_body"
|
||||
echo "Status: $http_code"
|
||||
echo "Body: $response_body"
|
||||
|
||||
if [ "$http_code" -eq 200 ]; then
|
||||
echo "✅ Uptime checks completed"
|
||||
else
|
||||
echo "❌ Uptime checks failed: $http_code"
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
DEPLOYMENT_URL: ${{ secrets.DEPLOYMENT_URL }}
|
||||
|
||||
scan:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.schedule == '0 */6 * * *' || github.event.inputs.mode == 'scan' || github.event.inputs.mode == 'all'
|
||||
steps:
|
||||
- name: Trigger Lighthouse Scan
|
||||
run: |
|
||||
DEPLOYMENT_URL="${DEPLOYMENT_URL:-https://your-domain.com}"
|
||||
echo "Triggering scan at: $DEPLOYMENT_URL/api/cron/scan?mode=all"
|
||||
|
||||
response=$(curl -s -w "\n%{http_code}" -X POST "$DEPLOYMENT_URL/api/cron/scan?mode=all")
|
||||
http_code=$(echo "$response" | tail -n1)
|
||||
response_body=$(echo "$response" | head -n -1)
|
||||
|
||||
echo "Status: $http_code"
|
||||
echo "Body: $response_body"
|
||||
|
||||
# Check if the request was successful
|
||||
if [ "$http_code" -eq 200 ]; then
|
||||
echo "✅ Scan triggered successfully"
|
||||
else
|
||||
echo "❌ Failed to trigger scan. Status: $http_code"
|
||||
echo "❌ Failed to trigger scan: $http_code"
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
|
||||
Reference in New Issue
Block a user