Skip to content

Commit 4069c1b

Browse files
committed
feat: demo final deploy fixes
1 parent 2cb1269 commit 4069c1b

File tree

6 files changed

+58
-34
lines changed

6 files changed

+58
-34
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,13 @@ jobs:
183183
deploy-demo:
184184
needs: [build-and-test, edge-worker-e2e]
185185
runs-on: ubuntu-latest
186-
# Only run on main branch pushes (production) - skip PRs for now
187-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
188-
environment: production
186+
environment: ${{ github.event_name == 'pull_request' && 'preview' || 'production' }}
189187
env:
190188
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
191189
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
192190
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
193-
# Hardcoded for testing - these are public values
194-
VITE_SUPABASE_URL: https://bsgbmmbmlmcmdnheuwmt.supabase.co
195-
VITE_SUPABASE_ANON_KEY: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImJzZ2JtbWJtbG1jbWRuaGV1d210Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjIzNDA2NzIsImV4cCI6MjA3NzkxNjY3Mn0.Uoy8iqxycrqd4b6LPMMXWWSYrP1BDRMrJVgM2_vtl6o
191+
VITE_SUPABASE_URL: ${{ github.event_name == 'pull_request' && secrets.DEMO_PREVIEW_SUPABASE_URL || secrets.DEMO_PRODUCTION_SUPABASE_URL }}
192+
VITE_SUPABASE_ANON_KEY: ${{ github.event_name == 'pull_request' && secrets.DEMO_PREVIEW_SUPABASE_ANON_KEY || secrets.DEMO_PRODUCTION_SUPABASE_ANON_KEY }}
196193
steps:
197194
- uses: actions/checkout@v4
198195
with:
@@ -206,19 +203,7 @@ jobs:
206203
- name: Verify NX_BASE and NX_HEAD are set
207204
run: echo "BASE=$NX_BASE HEAD=$NX_HEAD"
208205

209-
- name: Check if demo is affected
210-
id: check-affected
211-
run: |
212-
if pnpm nx show projects --affected -t build --base="$NX_BASE" --head="$NX_HEAD" | grep -q "^demo$"; then
213-
echo "affected=true" >> $GITHUB_OUTPUT
214-
echo "Demo is affected by changes"
215-
else
216-
echo "affected=false" >> $GITHUB_OUTPUT
217-
echo "Demo is not affected by changes - skipping deployment"
218-
fi
219-
220206
- name: Validate Supabase environment variables
221-
if: steps.check-affected.outputs.affected == 'true'
222207
run: |
223208
if [ -z "$VITE_SUPABASE_URL" ]; then
224209
echo "❌ Error: VITE_SUPABASE_URL is not set"
@@ -237,18 +222,22 @@ jobs:
237222
fi
238223
echo "✅ Supabase environment variables are valid"
239224
240-
- name: Deploy demo to production
225+
- name: Deploy demo
241226
id: deploy-demo
242-
if: steps.check-affected.outputs.affected == 'true'
227+
env:
228+
PREVIEW_NAME: pr-${{ github.event.pull_request.number }}
243229
run: |
244-
echo "Deploying demo to production (demo.pgflow.dev)..."
245-
pnpm nx run demo:deploy --skip-nx-cache
230+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
231+
pnpm nx affected -t deploy:preview --projects=demo --base="$NX_BASE" --head="$NX_HEAD"
232+
else
233+
pnpm nx affected -t deploy --projects=demo --base="$NX_BASE" --head="$NX_HEAD"
234+
fi
246235
247236
- name: Post deployment comment
248-
if: always()
237+
if: success()
249238
uses: ./.github/actions/deployment-comment
250239
with:
251240
project-name: Demo
241+
preview-url: https://pr-${{ github.event.pull_request.number }}-pgflow-demo.jumski.workers.dev
252242
production-url: https://demo.pgflow.dev
253-
# No preview URL - we only deploy production from main branch
254243

apps/demo/project.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@
2626
"command": "vite build",
2727
"cwd": "apps/demo"
2828
},
29-
"outputs": ["{projectRoot}/.svelte-kit"]
29+
"outputs": ["{projectRoot}/.svelte-kit"],
30+
"inputs": [
31+
"{projectRoot}/wrangler.toml",
32+
{
33+
"env": "VITE_SUPABASE_URL"
34+
},
35+
{
36+
"env": "VITE_SUPABASE_ANON_KEY"
37+
}
38+
]
3039
},
3140
"preview": {
3241
"executor": "nx:run-commands",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- Create extensions and required schemas for pgflow demo
2+
3+
-- Enable pg_cron extension
4+
CREATE EXTENSION IF NOT EXISTS pg_cron WITH SCHEMA pg_catalog;
5+
6+
-- Enable pg_net extension
7+
CREATE EXTENSION IF NOT EXISTS pg_net;
8+
9+
-- Create cron schema if it doesn't exist
10+
CREATE SCHEMA IF NOT EXISTS cron;
11+
12+
-- Create net schema if it doesn't exist
13+
CREATE SCHEMA IF NOT EXISTS net;
14+
15+
-- Grant permissions to postgres role
16+
GRANT USAGE ON SCHEMA cron TO postgres;
17+
GRANT USAGE ON SCHEMA net TO postgres;
18+
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA cron TO postgres;

apps/demo/supabase/seeds/watchdog_article_worker.sql

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
-- Enable required extensions
2-
CREATE EXTENSION IF NOT EXISTS pg_cron;
3-
CREATE EXTENSION IF NOT EXISTS pg_net;
4-
5-
-- Grant necessary permissions
6-
GRANT USAGE ON SCHEMA cron TO postgres;
7-
GRANT USAGE ON SCHEMA net TO postgres;
8-
91
-- Remove existing job if it exists to prevent duplicates
102
SELECT cron.unschedule(jobname)
113
FROM cron.job

examples/playground/project.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
"executor": "@nx/next:build",
1010
"outputs": ["{projectRoot}/.next"],
1111
"defaultConfiguration": "production",
12+
"inputs": [
13+
"default",
14+
"^production",
15+
{
16+
"env": "NEXT_PUBLIC_SUPABASE_URL"
17+
},
18+
{
19+
"env": "NEXT_PUBLIC_SUPABASE_ANON_KEY"
20+
}
21+
],
1222
"options": {
1323
"outputPath": "{projectRoot}"
1424
},

pkgs/website/project.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
"executor": "nx:run-commands",
1010
"inputs": [
1111
"default",
12-
"^production"
12+
"^production",
13+
{
14+
"env": "VITE_SUPABASE_URL"
15+
},
16+
{
17+
"env": "VITE_SUPABASE_ANON_KEY"
18+
}
1319
],
1420
"outputs": ["{options.outputPath}"],
1521
"options": {

0 commit comments

Comments
 (0)