Skip to content

Commit a529687

Browse files
authored
Merge pull request #503 from webstackdev/infrastructure/migrate-to-astro-db-from-suprabase-and-upstash
Infrastructure/migrate to astro db from suprabase and upstash
2 parents 553ee20 + 0c1e676 commit a529687

106 files changed

Lines changed: 3571 additions & 5130 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cache/pages.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,10 @@
2222
"contact",
2323
"offline",
2424
{
25-
"privacy": [
26-
"my-data"
27-
]
25+
"privacy": ["my-data"]
2826
},
2927
{
30-
"services": [
31-
"consulting",
32-
"overview",
33-
"web-development"
34-
]
28+
"services": ["consulting", "overview", "web-development"]
3529
},
3630
{
3731
"tags": [
@@ -53,4 +47,4 @@
5347
"typescript"
5448
]
5549
}
56-
]
50+
]

.env.example

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,6 @@ CRON_SECRET="local-cron-secret"
2020
RESEND_HTTP_PORT="9011"
2121
RESEND_API_KEY="mock-resend-key"
2222

23-
# Upstash-compatible Redis mock for rate limits + cron keepalive keys (local
24-
# and on GitHub Actions, production on Vercel)
25-
UPSTASH_HTTP_PORT="8079"
26-
UPSTASH_REDIS_PORT="6380"
27-
UPSTASH_TOKEN="local-dev-token"
28-
29-
# Vercel Marketplace Integration for Upstash Redis used with rate limiting on API endpoints
30-
# (local and on GitHub Actions, production on Vercel)
31-
KV_URL="redis://default:local-dev-token@127.0.0.1:6380"
32-
KV_REST_API_URL="http://127.0.0.1:8079"
33-
KV_REST_API_TOKEN="local-dev-token"
34-
KV_REST_API_READ_ONLY_TOKEN="local-dev-token"
35-
REDIS_URL="redis://default:local-dev-token@127.0.0.1:6380"
36-
37-
# Supabase configuration
38-
# - SUPABASE_URL / SUPABASE_KEY: client + server runtime credentials used in Astro and API routes.
39-
# - SUPABASE_SERVICE_ROLE_KEY: server-side key for tests and cron endpoints (never expose to browser).
40-
# - SUPABASE_HEALTH_TIMEOUT: controls how long we wait for the local Supabase container to become healthy.
41-
# - SUPABASE_DB_PASSWORD / SUPABASE_PROJECT_REF / SUPABASE_ACCESS_TOKEN: only needed when pushing
42-
# migrations to the hosted project (GitHub "build" workflow). Leave them empty locally unless you
43-
# have production access.
44-
SUPABASE_HEALTH_TIMEOUT="240"
45-
SUPABASE_URL="http://127.0.0.1:54321"
46-
SUPABASE_KEY="sb_publishable_example"
47-
SUPABASE_SERVICE_ROLE_KEY="sb_secret_example"
48-
SUPABASE_DB_PASSWORD="example-db-password"
49-
SUPABASE_PROJECT_REF="exampleprojectref"
50-
SUPABASE_ACCESS_TOKEN="sbp_example_personal_access_token"
51-
5223
# Observability / external services
5324
SENTRY_AUTH_TOKEN="dev-placeholder-sentry-token"
5425
SENTRY_DSN="https://examplePublicKey@o0.ingest.sentry.io/0"
@@ -60,3 +31,8 @@ VERCEL_ORG_ID="team_C7kQw5vXn0PfH3sJt2Gb9LrY"
6031

6132
# Used for social shares on Mastodon
6233
WEBMENTION_IO_TOKEN="dev-webmention-token"
34+
35+
# Astro DB - local file-backed dev database (token unused for file connections)
36+
ASTRO_DB_REMOTE_URL="file:./.astro/content.db"
37+
ASTRO_DB_APP_TOKEN=""
38+
# ASTRO_DATABASE_FILE must be exported in the shell (see README)

.github/workflows/branch-protection.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
pull_request:
55
types: [opened, edited, synchronize, reopened]
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
check-branch-name:
912
name: Validate Branch Name

.github/workflows/build.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
types:
88
- completed
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
1114
verify-ci:
1215
name: Verify CI Results
@@ -37,8 +40,8 @@ jobs:
3740
core.setFailed(`Required CI jobs missing or failed: ${missing.join(', ')}`);
3841
}
3942
40-
push-supabase-migrations:
41-
name: Push Supabase Production Migrations
43+
push-turso-migrations:
44+
name: Push Turso Production Migrations
4245
runs-on: ubuntu-latest
4346
needs: verify-ci
4447
if: >-
@@ -53,15 +56,17 @@ jobs:
5356
with:
5457
ref: ${{ github.event.workflow_run.head_sha }}
5558

56-
- name: Install Supabase CLI
57-
uses: supabase/setup-cli@v1.6.0
59+
- name: Setup Node.js
60+
uses: actions/setup-node@v6
5861
with:
59-
version: latest
62+
node-version: '22.x'
63+
cache: 'npm'
6064

61-
- name: Link Supabase project
62-
run: supabase link --project-ref ${{ secrets.SUPABASE_PROJECT_REF }} --password "${{ secrets.SUPABASE_DB_PASSWORD }}" --workdir suprabase
63-
env:
64-
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
65+
- name: Install dependencies
66+
run: npm ci --legacy-peer-deps
6567

66-
- name: Push migrations to production
67-
run: supabase db push --workdir suprabase
68+
- name: Push Astro DB migrations to Turso
69+
run: npx astro db push --remote
70+
env:
71+
ASTRO_DB_REMOTE_URL: ${{ secrets.ASTRO_DB_REMOTE_URL }}
72+
ASTRO_DB_APP_TOKEN: ${{ secrets.ASTRO_DB_APP_TOKEN }}

.github/workflows/ping-turso.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Ping Turso
2+
3+
on:
4+
schedule:
5+
- cron: '*/30 * * * *'
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ping-turso
13+
cancel-in-progress: true
14+
15+
jobs:
16+
ping:
17+
name: Ping Turso Production DB
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v6
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v6
26+
with:
27+
node-version: '22.x'
28+
cache: 'npm'
29+
30+
- name: Install dependencies
31+
run: npm ci --legacy-peer-deps
32+
33+
- name: Execute keep-alive query
34+
env:
35+
ASTRO_DB_REMOTE_URL: ${{ secrets.ASTRO_DB_REMOTE_URL }}
36+
ASTRO_DB_APP_TOKEN: ${{ secrets.ASTRO_DB_APP_TOKEN }}
37+
run: |
38+
node --input-type=module -e "\
39+
import { createClient } from '@libsql/client';\
40+
const url = process.env.ASTRO_DB_REMOTE_URL;\
41+
const authToken = process.env.ASTRO_DB_APP_TOKEN;\
42+
if (!url || !authToken) {\
43+
throw new Error('Missing ASTRO_DB_REMOTE_URL or ASTRO_DB_APP_TOKEN');\
44+
}\
45+
const client = createClient({ url, authToken });\
46+
try {\
47+
await client.execute('SELECT 1');\
48+
console.log('[ping-turso] OK');\
49+
} finally {\
50+
client.close();\
51+
}\
52+
"

0 commit comments

Comments
 (0)