Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,29 +124,36 @@ jobs:

- name: Start Supabase
run: |
pnpm run supabase start > supabase_output.txt 2>&1
pnpm run supabase start
echo "Supabase started successfully"
pnpm run supabase migration up
echo "Supabase migrations applied successfully"

- name: Create Environment File
run: |
# Extract anon key and service key from Supabase output
# Handle the exact format with leading spaces for anon key
ANON_KEY=$(grep -E '^\s+anon key:' supabase_output.txt | sed 's/.*anon key: //')
SERVICE_KEY=$(grep -E '^service_role key:' supabase_output.txt | sed 's/.*service_role key: //')
# Extract anon key and service key from supabase status output
SUPABASE_STATUS=$(pnpm run --silent supabase status 2>&1)

ANON_KEY=$(echo "$SUPABASE_STATUS" | grep 'anon key:' | sed 's/.*anon key: //' | head -1)
SERVICE_KEY=$(echo "$SUPABASE_STATUS" | grep 'service_role key:' | sed 's/.*service_role key: //' | head -1)

# Fallback: extract JWT tokens directly if the above fails
if [ -z "$ANON_KEY" ] || [ -z "$SERVICE_KEY" ]; then
echo "Primary extraction failed, trying JWT pattern matching..."
# Extract all JWT tokens and assign them based on position
TOKENS=($(grep -oE 'eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*' supabase_output.txt))
TOKENS=($(echo "$SUPABASE_STATUS" | grep -oE 'eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*' || true))
if [ ${#TOKENS[@]} -ge 2 ]; then
ANON_KEY=${TOKENS[0]}
SERVICE_KEY=${TOKENS[1]}
fi
fi

if [ -z "$ANON_KEY" ] || [ -z "$SERVICE_KEY" ]; then
echo "Failed to extract Supabase keys. Supabase status output:"
echo "$SUPABASE_STATUS"
exit 1
fi

echo "VITE_SUPABASE_URL=http://localhost:54321" > .env.local
echo "VITE_SUPABASE_ANON_KEY=$ANON_KEY" >> .env.local
echo "DANGER_SUPABASE_SERVICE_KEY=$SERVICE_KEY" >> .env.local
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@emoji-mart/data": "^1.2.1",
"@emoji-mart/react": "^1.1.1",
"@eslint/js": "^9.30.1",
"@supabase/supabase-js": "^2.50.4",
"@supabase/supabase-js": "^2.99.1",
"@tailwindcss/vite": "^4.2.1",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.1.6",
Expand All @@ -37,7 +37,7 @@
"react-dom": "^19.1.0",
"react-icons": "^5.6.0",
"react-router": "^7.13.1",
"supabase": "^2.30.4",
"supabase": "^2.78.1",
"tailwindcss": "^4.2.1",
"typescript": "~5.8.3",
"typescript-eslint": "^8.36.0",
Expand All @@ -55,5 +55,8 @@
"sharp",
"supabase"
]
},
"devDependencies": {
"@types/node": "^25.5.0"
}
}
Loading
Loading