Download .github/workflows/keep-alive.yaml from ilhamdev/quote-api: direct link, hf CLI and curl.
- Browser
- Download file 2.39 kB
-
https://huggingface.co/spaces/ilhamdev/quote-api/resolve/main/.github/workflows/keep-alive.yaml
- Command line
-
hf download hf://spaces/ilhamdev/quote-api/.github/workflows/keep-alive.yaml
-
curl -L -o keep-alive.yaml https://huggingface.co/spaces/ilhamdev/quote-api/resolve/main/.github/workflows/keep-alive.yaml
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." | |