5353 - name : Build all affected projects (except playground)
5454 run : pnpm nx affected -t build --configuration=production --parallel --exclude=playground --base="$NX_BASE" --head="$NX_HEAD"
5555
56+ - name : Verify exports for built packages
57+ run : pnpm nx affected -t verify-exports --base="$NX_BASE" --head="$NX_HEAD"
58+
5659
5760# ─────────────────────────────────────── 2. EDGE-WORKER E2E ──────────────────────────────────────
5861 edge-worker-e2e :
@@ -101,49 +104,7 @@ jobs:
101104 run : pnpm nx affected -t test:e2e --parallel --base="$NX_BASE" --head="$NX_HEAD"
102105
103106
104- # ────────────────────────────────── 3. DEPLOY PLAYGROUND ───────────────────────────
105- deploy-playground :
106- needs : [build-and-test, edge-worker-e2e]
107- if : false # Disabled
108- # if: >-
109- # ${{
110- # (github.event_name == 'pull_request') ||
111- # (github.ref == 'refs/heads/main' && github.event_name == 'push')
112- # }}
113- runs-on : ubuntu-latest
114- environment : ${{ github.event_name == 'pull_request' && 'preview' || 'production' }}
115- env :
116- NX_CLOUD_ACCESS_TOKEN : ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
117- NETLIFY_AUTH_TOKEN : ${{ secrets.NETLIFY_AUTH_TOKEN }}
118- NETLIFY_SITE_ID : ${{ secrets.NETLIFY_PLAYGROUND_SITE_ID }}
119- NEXT_PUBLIC_SUPABASE_URL : ${{ github.event_name == 'pull_request' && secrets.DEMO_PREVIEW_SUPABASE_URL || secrets.DEMO_PRODUCTION_SUPABASE_URL }}
120- NEXT_PUBLIC_SUPABASE_ANON_KEY : ${{ github.event_name == 'pull_request' && secrets.DEMO_PREVIEW_SUPABASE_ANON_KEY || secrets.DEMO_PRODUCTION_SUPABASE_ANON_KEY }}
121- steps :
122- - uses : actions/checkout@v4
123- with :
124- fetch-depth : 0
125-
126- - uses : ./.github/actions/setup
127-
128- # Build the workspace libraries that the app imports
129- - run : pnpm nx run-many -t build --projects client,dsl --configuration=production
130-
131- - name : Build & deploy to Netlify
132- id : deploy
133- run : |
134- pnpm netlify deploy --build --filter=playground \
135- --context ${{ github.event_name == 'pull_request' && 'deploy-preview' || 'production' }} \
136- ${{ github.event_name == 'pull_request' && format('--alias=pr-{0}', github.event.pull_request.number) || '--prod' }}
137-
138- - name : Post deployment comment
139- if : always()
140- uses : ./.github/actions/deployment-comment
141- with :
142- project-name : Playground
143- preview-url : https://pr-${{ github.event.pull_request.number }}--pgflow-demo.netlify.app
144- production-url : https://playground.pgflow.dev
145-
146- # ────────────────────────────────── 4. DEPLOY WEBSITE ───────────────────────────
107+ # ────────────────────────────────── 3. DEPLOY WEBSITE ───────────────────────────
147108 deploy-website :
148109 needs : [build-and-test, edge-worker-e2e]
149110 runs-on : ubuntu-latest
@@ -179,7 +140,27 @@ jobs:
179140 echo "affected=false" >> $GITHUB_OUTPUT
180141 echo "Website is not affected by changes - skipping deployment"
181142 fi
182-
143+
144+ - name : Validate Supabase environment variables
145+ if : steps.check-affected.outputs.affected == 'true'
146+ run : |
147+ if [ -z "$VITE_SUPABASE_URL" ]; then
148+ echo "❌ Error: VITE_SUPABASE_URL is not set"
149+ echo "Required GitHub secret missing: WEBSITE_${{ github.event_name == 'pull_request' && 'PREVIEW' || 'PRODUCTION' }}_SUPABASE_URL"
150+ exit 1
151+ fi
152+ if [ -z "$VITE_SUPABASE_ANON_KEY" ]; then
153+ echo "❌ Error: VITE_SUPABASE_ANON_KEY is not set"
154+ echo "Required GitHub secret missing: WEBSITE_${{ github.event_name == 'pull_request' && 'PREVIEW' || 'PRODUCTION' }}_SUPABASE_ANON_KEY"
155+ exit 1
156+ fi
157+ if [[ ! "$VITE_SUPABASE_URL" =~ ^https:// ]]; then
158+ echo "❌ Error: VITE_SUPABASE_URL must use https:// (not http://)"
159+ echo "Current value: $VITE_SUPABASE_URL"
160+ exit 1
161+ fi
162+ echo "✅ Supabase environment variables are valid"
163+
183164 - name : Deploy website
184165 id : deploy-website
185166 if : steps.check-affected.outputs.affected == 'true'
@@ -200,3 +181,76 @@ jobs:
200181 preview-url : https://pr-${{ github.event.pull_request.number }}.pgflow.pages.dev
201182 production-url : https://pgflow.dev
202183
184+ # ────────────────────────────────── 4. DEPLOY DEMO ───────────────────────────
185+ deploy-demo :
186+ needs : [build-and-test, edge-worker-e2e]
187+ runs-on : ubuntu-latest
188+ # Only run on main branch pushes (production) - skip PRs for now
189+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
190+ environment : production
191+ env :
192+ NX_CLOUD_ACCESS_TOKEN : ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
193+ CLOUDFLARE_API_TOKEN : ${{ secrets.CLOUDFLARE_API_TOKEN }}
194+ CLOUDFLARE_ACCOUNT_ID : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
195+ # Hardcoded for testing - these are public values
196+ VITE_SUPABASE_URL : https://bsgbmmbmlmcmdnheuwmt.supabase.co
197+ VITE_SUPABASE_ANON_KEY : eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImJzZ2JtbWJtbG1jbWRuaGV1d210Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjIzNDA2NzIsImV4cCI6MjA3NzkxNjY3Mn0.Uoy8iqxycrqd4b6LPMMXWWSYrP1BDRMrJVgM2_vtl6o
198+ steps :
199+ - uses : actions/checkout@v4
200+ with :
201+ fetch-depth : 0
202+
203+ - uses : ./.github/actions/setup
204+
205+ - name : Set Nx SHAs for affected commands
206+ uses : nrwl/nx-set-shas@v4
207+
208+ - name : Verify NX_BASE and NX_HEAD are set
209+ run : echo "BASE=$NX_BASE HEAD=$NX_HEAD"
210+
211+ - name : Check if demo is affected
212+ id : check-affected
213+ run : |
214+ if pnpm nx show projects --affected -t build --base="$NX_BASE" --head="$NX_HEAD" | grep -q "^demo$"; then
215+ echo "affected=true" >> $GITHUB_OUTPUT
216+ echo "Demo is affected by changes"
217+ else
218+ echo "affected=false" >> $GITHUB_OUTPUT
219+ echo "Demo is not affected by changes - skipping deployment"
220+ fi
221+
222+ - name : Validate Supabase environment variables
223+ if : steps.check-affected.outputs.affected == 'true'
224+ run : |
225+ if [ -z "$VITE_SUPABASE_URL" ]; then
226+ echo "❌ Error: VITE_SUPABASE_URL is not set"
227+ echo "Required GitHub secret missing: DEMO_${{ github.event_name == 'pull_request' && 'PREVIEW' || 'PRODUCTION' }}_SUPABASE_URL"
228+ exit 1
229+ fi
230+ if [ -z "$VITE_SUPABASE_ANON_KEY" ]; then
231+ echo "❌ Error: VITE_SUPABASE_ANON_KEY is not set"
232+ echo "Required GitHub secret missing: DEMO_${{ github.event_name == 'pull_request' && 'PREVIEW' || 'PRODUCTION' }}_SUPABASE_ANON_KEY"
233+ exit 1
234+ fi
235+ if [[ ! "$VITE_SUPABASE_URL" =~ ^https:// ]]; then
236+ echo "❌ Error: VITE_SUPABASE_URL must use https:// (not http://)"
237+ echo "Current value: $VITE_SUPABASE_URL"
238+ exit 1
239+ fi
240+ echo "✅ Supabase environment variables are valid"
241+
242+ - name : Deploy demo to production
243+ id : deploy-demo
244+ if : steps.check-affected.outputs.affected == 'true'
245+ run : |
246+ echo "Deploying demo to production (demo.pgflow.dev)..."
247+ pnpm nx run demo:deploy --skip-nx-cache
248+
249+ - name : Post deployment comment
250+ if : always()
251+ uses : ./.github/actions/deployment-comment
252+ with :
253+ project-name : Demo
254+ production-url : https://demo.pgflow.dev
255+ # No preview URL - we only deploy production from main branch
256+
0 commit comments