|
38 | 38 | version: 2.121.0 |
39 | 39 | # Ohne "supabase link": der braucht mehr Token-Rechte als nötig. |
40 | 40 | # Verbindung über den Supabase-Pooler (GitHub-Runner haben kein IPv6). |
| 41 | + # Kostenlose Supabase-Projekte pausieren nach ca. 1 Woche ohne Nutzung → hier automatisch aufwecken |
| 42 | + - name: Supabase-Projekt aufwecken (falls pausiert) |
| 43 | + run: | |
| 44 | + status() { curl -s -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" "https://api.supabase.com/v1/projects/$PROJECT_REF" | jq -r '.status // "unbekannt"'; } |
| 45 | + S=$(status); echo "Projektstatus: $S" |
| 46 | + if [ "$S" = "INACTIVE" ] || [ "$S" = "PAUSED" ]; then |
| 47 | + CODE=$(curl -s -o /tmp/restore.json -w '%{http_code}' -X POST -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" "https://api.supabase.com/v1/projects/$PROJECT_REF/restore") |
| 48 | + echo "Aufwecken angefordert: HTTP $CODE $(head -c 200 /tmp/restore.json)" |
| 49 | + if [ "$CODE" -ge 300 ]; then |
| 50 | + echo "::error::Supabase-Projekt ist pausiert und liess sich nicht automatisch aufwecken (HTTP $CODE). Bitte im Dashboard „Restore project“ wählen: https://supabase.com/dashboard/project/$PROJECT_REF" |
| 51 | + exit 1 |
| 52 | + fi |
| 53 | + fi |
| 54 | + # warten, bis Datenbank und Pooler bereit sind (max. 15 Min.) |
| 55 | + for i in $(seq 1 90); do |
| 56 | + S=$(status) |
| 57 | + [ "$S" = "ACTIVE_HEALTHY" ] && break |
| 58 | + echo "… $S"; sleep 10 |
| 59 | + done |
| 60 | + echo "Projektstatus: $S" |
| 61 | + if [ "$S" != "ACTIVE_HEALTHY" ]; then echo "::error::Supabase-Projekt ist nicht bereit (Status $S)."; exit 1; fi |
| 62 | + # Pooler-Konfiguration erscheint teils erst kurz nach dem Aufwachen |
| 63 | + for i in $(seq 1 18); do |
| 64 | + N=$(curl -s -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" "https://api.supabase.com/v1/projects/$PROJECT_REF/config/database/pooler" | jq 'if type=="array" then length else 1 end') |
| 65 | + [ "$N" != "0" ] && break |
| 66 | + echo "… Pooler noch nicht bereit"; sleep 10 |
| 67 | + done |
| 68 | +
|
41 | 69 | - name: Datenbank-Verbindung ermitteln |
42 | 70 | run: | |
43 | 71 | RES=$(curl -s -w '\n%{http_code}' -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ |
|
62 | 90 | STATUS=$(echo "$PROJ" | jq -r '.status // "unbekannt"'); REGION=$(echo "$PROJ" | jq -r '.region // "?"') |
63 | 91 | echo "Pooler-Liste leer — Projektstatus: $STATUS, Region: $REGION" |
64 | 92 | if [ "$STATUS" = "INACTIVE" ] || [ "$STATUS" = "PAUSED" ] || [ "$STATUS" = "PAUSING" ]; then |
65 | | - echo "::error::Das Supabase-Projekt $PROJECT_REF ist pausiert. Im Supabase-Dashboard öffnen und „Restore project“ wählen, danach den Deploy neu starten." |
| 93 | + echo "::error::Das Supabase-Projekt $PROJECT_REF ist noch pausiert. Im Dashboard „Restore project“ wählen: https://supabase.com/dashboard/project/$PROJECT_REF" |
66 | 94 | exit 1 |
67 | 95 | fi |
68 | 96 | # sonst: Verbindung über „supabase link“ ermitteln lassen (offizieller Weg der CLI) |
|
0 commit comments