quote-api / .github /workflows /keep-alive.yaml
ilhamdev's picture
feat: redesign to neubrutalism UI and secure Hugging Face Space from rate/resource limits
f6522be
Raw History Blame Contribute Delete
2.39 kB
name: Hugging Face Keep Alive
on:
schedule:
# Runs every 6 hours (00:00, 06:00, 12:00, 18:00 UTC) to prevent free-tier space sleeping
- cron: '0 */6 * * *'
workflow_dispatch: # Allows manual trigger from GitHub Actions tab
jobs:
keep-alive:
name: Ping Quote API Backend
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Ping Hugging Face Space Status Endpoint
run: |
echo "πŸ“‘ Checking Hugging Face backend status..."
HTTP_RESPONSE=$(curl -s -S --max-time 60 --retry 3 --retry-delay 5 -w "\n%{http_code}" \
-H "User-Agent: GitHub-Actions-KeepAlive/1.0" \
https://ilhamdev-quote-api.hf.space/status)
HTTP_BODY=$(echo "$HTTP_RESPONSE" | sed '$d')
HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tail -n 1)
echo "Response Status: $HTTP_STATUS"
echo "Response Body: $HTTP_BODY"
if [ "$HTTP_STATUS" -ne 200 ]; then
echo "❌ Hugging Face Space returned non-200 status code: $HTTP_STATUS"
exit 1
fi
echo "βœ… Hugging Face Space is active and awake!"
- name: Warm Up Canvas Rendering Engine (Lightweight POST)
run: |
echo "🎨 Sending lightweight ping payload to warm up canvas engine..."
PAYLOAD='{"type":"quote","format":"png","backgroundColor":"#1b1e23","messages":[{"from":{"id":1,"name":"KeepAlive","title":"Bot"},"text":"Ping"}]}'
HTTP_RESPONSE=$(curl -s -S --max-time 60 --retry 2 --retry-delay 5 -w "\n%{http_code}" \
-X POST \
-H "Content-Type: application/json" \
-H "User-Agent: GitHub-Actions-KeepAlive/1.0" \
-d "$PAYLOAD" \
https://ilhamdev-quote-api.hf.space/)
HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tail -n 1)
if [ "$HTTP_STATUS" -eq 200 ]; then
echo "βœ… Canvas rendering pipeline is warm and responsive!"
else
echo "⚠️ Non-200 status on render ping ($HTTP_STATUS), but container was contacted."
fi
- name: Ping Vercel Subdomain Proxy
run: |
echo "🌐 Checking Subdomain proxy (qc.mangrusdi.my.id)..."
curl -s -S --max-time 30 \
-H "User-Agent: GitHub-Actions-KeepAlive/1.0" \
https://qc.mangrusdi.my.id/status || true
echo "βœ… Proxy checked."