Keep Supabase awake #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Keep Supabase awake | |
| # Free-tier Supabase projects pause after 7 days without API activity. This | |
| # workflow pings the project once a day so the timer never elapses. The ping | |
| # is a single SELECT against qa_pairs which counts as database activity. | |
| on: | |
| schedule: | |
| - cron: "0 12 * * *" # daily at 12:00 UTC | |
| workflow_dispatch: # also runnable manually from the Actions tab | |
| jobs: | |
| ping: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 2 | |
| steps: | |
| - name: Validate secrets are configured | |
| env: | |
| SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | |
| SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }} | |
| run: | | |
| if [ -z "$SUPABASE_URL" ] || [ -z "$SUPABASE_ANON_KEY" ]; then | |
| echo "::error::SUPABASE_URL and SUPABASE_ANON_KEY must be set in repo Settings -> Secrets and variables -> Actions" | |
| exit 1 | |
| fi | |
| - name: Ping REST API | |
| env: | |
| SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | |
| SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }} | |
| run: | | |
| STATUS=$(curl -sS -o /tmp/resp.txt -w "%{http_code}" \ | |
| "${SUPABASE_URL%/}/rest/v1/qa_pairs?limit=1" \ | |
| -H "apikey: ${SUPABASE_ANON_KEY}" \ | |
| -H "Authorization: Bearer ${SUPABASE_ANON_KEY}") | |
| echo "HTTP ${STATUS}" | |
| # 200 (rows returned) and 401 (RLS blocked, but the request still hit | |
| # the database) both count as activity for pause-prevention purposes. | |
| if [ "$STATUS" != "200" ] && [ "$STATUS" != "401" ]; then | |
| echo "::error::Unexpected status ${STATUS} from Supabase" | |
| cat /tmp/resp.txt | |
| exit 1 | |
| fi | |
| echo "Supabase project pinged successfully." |