#!/bin/bash # Lighthouse Scanner Cron Job Setup Script # This script helps you set up automated scanning for your website monitoring application set -e echo "🚀 Lighthouse Scanner Cron Job Setup" echo "=====================================" # Check if we're in the right directory if [ ! -f "package.json" ]; then echo "❌ Error: Please run this script from your project root directory" exit 1 fi # Check if vercel.json exists if [ -f "vercel.json" ]; then echo "✅ Found vercel.json - Vercel cron jobs are configured" echo " Schedule: Every 6 hours" echo " Endpoint: /api/cron/scan?mode=all" echo "" echo "📝 To deploy with Vercel cron jobs:" echo " 1. Deploy to Vercel: vercel --prod" echo " 2. Cron jobs will start automatically" echo "" fi # Check if GitHub Actions workflow exists if [ -f ".github/workflows/cron-scan.yml" ]; then echo "✅ Found GitHub Actions workflow" echo " Schedule: Every 6 hours" echo " File: .github/workflows/cron-scan.yml" echo "" echo "📝 To use GitHub Actions:" echo " 1. Push this repository to GitHub" echo " 2. Set DEPLOYMENT_URL secret in repository settings" echo " 3. Workflow will run automatically" echo "" fi # Check environment variables echo "🔧 Environment Check:" if [ -f ".env" ]; then echo "✅ Found .env file" # Check for required Supabase variables if grep -q "NEXT_PUBLIC_SUPABASE_URL" .env; then echo "✅ NEXT_PUBLIC_SUPABASE_URL is configured" else echo "❌ NEXT_PUBLIC_SUPABASE_URL is missing" fi if grep -q "NEXT_PUBLIC_SUPABASE_ANON_KEY" .env; then echo "✅ NEXT_PUBLIC_SUPABASE_ANON_KEY is configured" else echo "❌ NEXT_PUBLIC_SUPABASE_ANON_KEY is missing" fi if grep -q "SUPABASE_SERVICE_ROLE_KEY" .env; then echo "✅ SUPABASE_SERVICE_ROLE_KEY is configured" else echo "❌ SUPABASE_SERVICE_ROLE_KEY is missing" fi else echo "❌ No .env file found" echo " Please create .env file with your Supabase configuration" fi echo "" echo "📚 Documentation:" echo " - Cron setup guide: docs/cron-setup-guide.md" echo " - Database setup: setup-database.sql" echo "" echo "🎯 Next Steps:" echo " 1. Ensure your database is set up with all required tables" echo " 2. Configure your environment variables" echo " 3. Deploy your application" echo " 4. Set up cron jobs using one of the methods above" echo " 5. Test the system by visiting your dashboard" echo "" echo "🔍 Testing:" echo " You can test the cron endpoint manually:" echo " curl -X POST 'https://your-domain.com/api/cron/scan?mode=all'" echo "" echo "✅ Setup complete! Check the documentation for detailed instructions."