Skip to content

Commit b330b22

Browse files
kutcodeclaude
andcommitted
Add keep-alive workflow to prevent Supabase free-tier pauses
Daily cron pings the REST API for qa_pairs which counts as activity and resets the 7-day inactivity timer. Requires SUPABASE_URL and SUPABASE_ANON_KEY repo secrets; the workflow fails fast if they are missing rather than appearing to succeed silently. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 56c78e0 commit b330b22

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

.github/workflows/keep-alive.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Keep Supabase awake
2+
3+
# Free-tier Supabase projects pause after 7 days without API activity. This
4+
# workflow pings the project once a day so the timer never elapses. The ping
5+
# is a single SELECT against qa_pairs which counts as database activity.
6+
7+
on:
8+
schedule:
9+
- cron: "0 12 * * *" # daily at 12:00 UTC
10+
workflow_dispatch: # also runnable manually from the Actions tab
11+
12+
jobs:
13+
ping:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 2
16+
steps:
17+
- name: Validate secrets are configured
18+
env:
19+
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
20+
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
21+
run: |
22+
if [ -z "$SUPABASE_URL" ] || [ -z "$SUPABASE_ANON_KEY" ]; then
23+
echo "::error::SUPABASE_URL and SUPABASE_ANON_KEY must be set in repo Settings -> Secrets and variables -> Actions"
24+
exit 1
25+
fi
26+
27+
- name: Ping REST API
28+
env:
29+
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
30+
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
31+
run: |
32+
STATUS=$(curl -sS -o /tmp/resp.txt -w "%{http_code}" \
33+
"${SUPABASE_URL%/}/rest/v1/qa_pairs?limit=1" \
34+
-H "apikey: ${SUPABASE_ANON_KEY}" \
35+
-H "Authorization: Bearer ${SUPABASE_ANON_KEY}")
36+
echo "HTTP ${STATUS}"
37+
# 200 (rows returned) and 401 (RLS blocked, but the request still hit
38+
# the database) both count as activity for pause-prevention purposes.
39+
if [ "$STATUS" != "200" ] && [ "$STATUS" != "401" ]; then
40+
echo "::error::Unexpected status ${STATUS} from Supabase"
41+
cat /tmp/resp.txt
42+
exit 1
43+
fi
44+
echo "Supabase project pinged successfully."

0 commit comments

Comments
 (0)