Keep Supabase Alive #620
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 Alive | |
| on: | |
| schedule: | |
| # Run every 12 hours (6 times a day) | |
| - cron: "0 */12 * * *" | |
| workflow_dispatch: # Allow manual trigger | |
| jobs: | |
| ping-supabase: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Ping Supabase (Primary) | |
| id: ping-primary | |
| continue-on-error: true | |
| env: | |
| NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }} | |
| NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }} | |
| run: node scripts/ping-supabase.js | |
| - name: Ping Supabase (Fallback) | |
| if: steps.ping-primary.outcome == 'failure' | |
| env: | |
| NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }} | |
| NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }} | |
| run: node scripts/ping-supabase-generic.js | |
| - name: Ping via HTTP (Last Resort) | |
| if: steps.ping-primary.outcome == 'failure' | |
| run: | | |
| echo "Attempting HTTP ping to Supabase..." | |
| curl -f "${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}/rest/v1/" \ | |
| -H "apikey: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}" \ | |
| -H "Authorization: Bearer ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}" \ | |
| || echo "HTTP ping failed, but that's okay - the connection attempt helps keep it alive" |