-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (50 loc) · 1.83 KB
/
Copy pathcron-alerts.yml
File metadata and controls
60 lines (50 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Check Alerts Cron
on:
# Run every 5 minutes
schedule:
- cron: '*/5 * * * *'
# Allow manual trigger from GitHub UI
workflow_dispatch:
jobs:
check-alerts:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Call AlertFrame Cron Endpoint
run: |
echo "🔍 Calling cron endpoint at $(date)"
echo "URL: ${{ secrets.VERCEL_APP_URL || 'https://alertframe.vercel.app' }}/api/cron/check-alerts"
RESPONSE=$(curl -X GET \
-H "Authorization: Bearer ${{ secrets.CRON_SECRET }}" \
-H "User-Agent: GitHub-Actions-Cron" \
-w "\n%{http_code}" \
-s \
"${{ secrets.VERCEL_APP_URL || 'https://alertframe.vercel.app' }}/api/cron/check-alerts")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | head -n-1)
echo ""
echo "📊 Response Code: $HTTP_CODE"
echo "📄 Response Body:"
echo "$BODY" | jq '.' || echo "$BODY"
if [ "$HTTP_CODE" != "200" ]; then
echo ""
echo "❌ Error: Cron endpoint returned $HTTP_CODE"
exit 1
fi
echo ""
echo "✅ Cron executed successfully"
- name: Notify on Failure
if: failure()
run: |
echo ""
echo "❌ Cron endpoint failed!"
echo "📝 Possible causes:"
echo " • Vercel app is down or deploying"
echo " • API endpoint error (check Vercel logs)"
echo " • CRON_SECRET is incorrect"
echo " • Network timeout"
echo ""
echo "🔧 Next steps:"
echo " 1. Check Vercel deployment status"
echo " 2. View Vercel logs for errors"
echo " 3. Test endpoint manually: curl https://your-app.vercel.app/api/cron/check-alerts"