@@ -2,9 +2,12 @@ name: Deploy to Vercel
22
33on :
44 # On push to main, deploy to production unconditionally.
5+ # On push to next, deploy a non-prod build aliased to `next.<app>.aztec-labs.com`
6+ # so the v5 cycle has stable URLs alongside production.
57 push :
68 branches :
79 - main
10+ - next
811 # On PRs, deploy preview after CI passes. pull_request_target runs in the
912 # context of the base repo so it has access to secrets (needed for Vercel
1013 # deploys + PR comments) — we wait for the CI workflow on the PR head to
@@ -150,11 +153,32 @@ jobs:
150153 - name : Install Vercel CLI
151154 run : npm install --global vercel@latest
152155
156+ # Map the GitHub event → Vercel env slot. Hobby tier only ships three
157+ # slots, so we reuse them: main → production, next → preview,
158+ # PRs → development. `vercel build` has no "development" target, so for
159+ # PR pulls we rename the dropped .env.development.local to .env.preview.local
160+ # so the subsequent preview build picks it up.
161+ - name : Resolve Vercel environment slot
162+ run : |
163+ if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then
164+ echo "VERCEL_ENV_SLOT=production" >> "$GITHUB_ENV"
165+ elif [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ "${{ inputs.production }}" == "true" ]; then
166+ echo "VERCEL_ENV_SLOT=production" >> "$GITHUB_ENV"
167+ elif [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/next" ]; then
168+ echo "VERCEL_ENV_SLOT=preview" >> "$GITHUB_ENV"
169+ else
170+ echo "VERCEL_ENV_SLOT=development" >> "$GITHUB_ENV"
171+ fi
172+
153173 # ── Bridge deployment ──────────────────────────────────────────────
154174 - name : Pull Vercel Environment (Bridge)
155175 env :
156176 VERCEL_PROJECT_ID : ${{ secrets.BRIDGE_PROJECT_ID }}
157- run : vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} --cwd apps/bridge
177+ run : |
178+ vercel pull --yes --environment=$VERCEL_ENV_SLOT --token=${{ secrets.VERCEL_TOKEN }} --cwd apps/bridge
179+ if [ "$VERCEL_ENV_SLOT" = "development" ] && [ -f apps/bridge/.vercel/.env.development.local ]; then
180+ mv apps/bridge/.vercel/.env.development.local apps/bridge/.vercel/.env.preview.local
181+ fi
158182
159183 - name : Build and deploy Bridge
160184 id : deploy-bridge
@@ -170,11 +194,23 @@ jobs:
170194 fi
171195 echo "url=$DEPLOY_URL" >> $GITHUB_OUTPUT
172196
197+ # On push to `next`, point next.bridge.aztec-labs.com at the just-built
198+ # preview deployment. Main's production aliases are untouched.
199+ - name : Alias Bridge to next subdomain
200+ if : github.event_name == 'push' && github.ref == 'refs/heads/next'
201+ env :
202+ VERCEL_PROJECT_ID : ${{ secrets.BRIDGE_PROJECT_ID }}
203+ run : vercel alias set ${{ steps.deploy-bridge.outputs.url }} next.bridge.aztec-labs.com --token=${{ secrets.VERCEL_TOKEN }} --scope=${{ secrets.VERCEL_ORG_ID }}
204+
173205 # ── FPC Operator deployment ────────────────────────────────────────
174206 - name : Pull Vercel Environment (FPC Operator)
175207 env :
176208 VERCEL_PROJECT_ID : ${{ secrets.FPC_PROJECT_ID }}
177- run : vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} --cwd apps/fpc-operator
209+ run : |
210+ vercel pull --yes --environment=$VERCEL_ENV_SLOT --token=${{ secrets.VERCEL_TOKEN }} --cwd apps/fpc-operator
211+ if [ "$VERCEL_ENV_SLOT" = "development" ] && [ -f apps/fpc-operator/.vercel/.env.development.local ]; then
212+ mv apps/fpc-operator/.vercel/.env.development.local apps/fpc-operator/.vercel/.env.preview.local
213+ fi
178214
179215 - name : Build and deploy FPC Operator
180216 id : deploy-fpc
@@ -191,11 +227,21 @@ jobs:
191227 fi
192228 echo "url=$DEPLOY_URL" >> $GITHUB_OUTPUT
193229
230+ - name : Alias FPC Operator to next subdomain
231+ if : github.event_name == 'push' && github.ref == 'refs/heads/next'
232+ env :
233+ VERCEL_PROJECT_ID : ${{ secrets.FPC_PROJECT_ID }}
234+ run : vercel alias set ${{ steps.deploy-fpc.outputs.url }} next.fpc-operator.aztec-labs.com --token=${{ secrets.VERCEL_TOKEN }} --scope=${{ secrets.VERCEL_ORG_ID }}
235+
194236 # ── Swap deployment ────────────────────────────────────────────────
195237 - name : Pull Vercel Environment (Swap)
196238 env :
197239 VERCEL_PROJECT_ID : ${{ secrets.SWAP_PROJECT_ID }}
198- run : vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} --cwd apps/swap
240+ run : |
241+ vercel pull --yes --environment=$VERCEL_ENV_SLOT --token=${{ secrets.VERCEL_TOKEN }} --cwd apps/swap
242+ if [ "$VERCEL_ENV_SLOT" = "development" ] && [ -f apps/swap/.vercel/.env.development.local ]; then
243+ mv apps/swap/.vercel/.env.development.local apps/swap/.vercel/.env.preview.local
244+ fi
199245
200246 - name : Build and deploy Swap
201247 id : deploy-swap
@@ -212,6 +258,12 @@ jobs:
212258 fi
213259 echo "url=$DEPLOY_URL" >> $GITHUB_OUTPUT
214260
261+ - name : Alias Swap to next subdomain
262+ if : github.event_name == 'push' && github.ref == 'refs/heads/next'
263+ env :
264+ VERCEL_PROJECT_ID : ${{ secrets.SWAP_PROJECT_ID }}
265+ run : vercel alias set ${{ steps.deploy-swap.outputs.url }} next.swap.aztec-labs.com --token=${{ secrets.VERCEL_TOKEN }} --scope=${{ secrets.VERCEL_ORG_ID }}
266+
215267 # ── PR Comment ─────────────────────────────────────────────────────
216268 - name : Comment deployment URLs on PR
217269 if : github.event_name == 'pull_request_target'
0 commit comments