Skip to content
Closed
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
37 changes: 13 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,13 @@ jobs:
deploy-demo:
needs: [build-and-test, edge-worker-e2e]
runs-on: ubuntu-latest
# Only run on main branch pushes (production) - skip PRs for now
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
environment: production
environment: ${{ github.event_name == 'pull_request' && 'preview' || 'production' }}
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
# Hardcoded for testing - these are public values
VITE_SUPABASE_URL: https://bsgbmmbmlmcmdnheuwmt.supabase.co
VITE_SUPABASE_ANON_KEY: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImJzZ2JtbWJtbG1jbWRuaGV1d210Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjIzNDA2NzIsImV4cCI6MjA3NzkxNjY3Mn0.Uoy8iqxycrqd4b6LPMMXWWSYrP1BDRMrJVgM2_vtl6o
VITE_SUPABASE_URL: ${{ github.event_name == 'pull_request' && secrets.DEMO_PREVIEW_SUPABASE_URL || secrets.DEMO_PRODUCTION_SUPABASE_URL }}
VITE_SUPABASE_ANON_KEY: ${{ github.event_name == 'pull_request' && secrets.DEMO_PREVIEW_SUPABASE_ANON_KEY || secrets.DEMO_PRODUCTION_SUPABASE_ANON_KEY }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -208,19 +205,7 @@ jobs:
- name: Verify NX_BASE and NX_HEAD are set
run: echo "BASE=$NX_BASE HEAD=$NX_HEAD"

- name: Check if demo is affected
id: check-affected
run: |
if pnpm nx show projects --affected -t build --base="$NX_BASE" --head="$NX_HEAD" | grep -q "^demo$"; then
echo "affected=true" >> $GITHUB_OUTPUT
echo "Demo is affected by changes"
else
echo "affected=false" >> $GITHUB_OUTPUT
echo "Demo is not affected by changes - skipping deployment"
fi

- name: Validate Supabase environment variables
if: steps.check-affected.outputs.affected == 'true'
run: |
if [ -z "$VITE_SUPABASE_URL" ]; then
echo "❌ Error: VITE_SUPABASE_URL is not set"
Expand All @@ -239,18 +224,22 @@ jobs:
fi
echo "✅ Supabase environment variables are valid"

- name: Deploy demo to production
- name: Deploy demo
id: deploy-demo
if: steps.check-affected.outputs.affected == 'true'
env:
PREVIEW_NAME: pr-${{ github.event.pull_request.number }}
run: |
echo "Deploying demo to production (demo.pgflow.dev)..."
pnpm nx run demo:deploy --skip-nx-cache
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
pnpm nx affected -t deploy:preview --projects=demo --base="$NX_BASE" --head="$NX_HEAD"
else
pnpm nx affected -t deploy --projects=demo --base="$NX_BASE" --head="$NX_HEAD"
fi

- name: Post deployment comment
if: always()
if: success()
uses: ./.github/actions/deployment-comment
with:
project-name: Demo
preview-url: https://pr-${{ github.event.pull_request.number }}-pgflow-demo.jumski.workers.dev
production-url: https://demo.pgflow.dev
# No preview URL - we only deploy production from main branch

11 changes: 10 additions & 1 deletion apps/demo/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@
"command": "vite build",
"cwd": "apps/demo"
},
"outputs": ["{projectRoot}/.svelte-kit"]
"outputs": ["{projectRoot}/.svelte-kit"],
"inputs": [
"{projectRoot}/wrangler.toml",
{
"env": "VITE_SUPABASE_URL"
},
{
"env": "VITE_SUPABASE_ANON_KEY"
}
]
},
"preview": {
"executor": "nx:run-commands",
Expand Down
18 changes: 18 additions & 0 deletions apps/demo/supabase/migrations/20251107224748_setup_extensions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- Create extensions and required schemas for pgflow demo

-- Enable pg_cron extension
CREATE EXTENSION IF NOT EXISTS pg_cron WITH SCHEMA pg_catalog;

-- Enable pg_net extension
CREATE EXTENSION IF NOT EXISTS pg_net;

-- Create cron schema if it doesn't exist
CREATE SCHEMA IF NOT EXISTS cron;

-- Create net schema if it doesn't exist
CREATE SCHEMA IF NOT EXISTS net;

-- Grant permissions to postgres role
GRANT USAGE ON SCHEMA cron TO postgres;
GRANT USAGE ON SCHEMA net TO postgres;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA cron TO postgres;
8 changes: 0 additions & 8 deletions apps/demo/supabase/seeds/watchdog_article_worker.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
-- Enable required extensions
CREATE EXTENSION IF NOT EXISTS pg_cron;
CREATE EXTENSION IF NOT EXISTS pg_net;

-- Grant necessary permissions
GRANT USAGE ON SCHEMA cron TO postgres;
GRANT USAGE ON SCHEMA net TO postgres;

-- Remove existing job if it exists to prevent duplicates
SELECT cron.unschedule(jobname)
FROM cron.job
Expand Down
8 changes: 7 additions & 1 deletion pkgs/website/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
"executor": "nx:run-commands",
"inputs": [
"default",
"^production"
"^production",
{
"env": "VITE_SUPABASE_URL"
},
{
"env": "VITE_SUPABASE_ANON_KEY"
}
],
"outputs": ["{options.outputPath}"],
"options": {
Expand Down
Loading