Keep Supabase Database Active #80
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
| # .github/workflows/keep-supabase-alive.yml | |
| name: Keep Supabase Database Active | |
| on: | |
| schedule: | |
| # Run every 5 days at different times to avoid patterns | |
| - cron: "0 14 */5 * *" # Every 5 days at 2 PM UTC | |
| - cron: "30 9 */5 * *" # Every 5 days at 9:30 AM UTC (offset) | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| ping-database: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Wait for random delay | |
| run: | | |
| # Add random delay to avoid predictable patterns | |
| delay=$((RANDOM % 300 + 60)) # Random delay between 1-5 minutes | |
| echo "Waiting $delay seconds before ping..." | |
| sleep $delay | |
| - name: Ping Health Check Endpoint | |
| run: | | |
| echo "π Attempting to ping health endpoint..." | |
| # Try the health endpoint with retry logic | |
| for i in {1..3}; do | |
| response=$(curl -s -o /dev/null -w "%{http_code}" --max-time 30 "${{ secrets.APP_URL }}/health/") | |
| if [ $response -eq 200 ]; then | |
| echo "β Health check successful on attempt $i (HTTP $response)" | |
| break | |
| else | |
| echo "β οΈ Health check failed on attempt $i (HTTP $response)" | |
| if [ $i -eq 3 ]; then | |
| echo "β All health check attempts failed" | |
| exit 1 | |
| fi | |
| sleep 10 | |
| fi | |
| done | |
| - name: Alternative Ping (if health endpoint fails) | |
| if: failure() | |
| run: | | |
| echo "π Trying alternative endpoint..." | |
| response=$(curl -s -o /dev/null -w "%{http_code}" --max-time 30 "${{ secrets.APP_URL }}/") | |
| echo "Main page response: HTTP $response" | |
| - name: Log Activity | |
| run: | | |
| echo "π― Database keep-alive ping completed at $(date)" | |
| echo "π Next scheduled run will be in ~5 days" |