Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
ci: label-gated hosted-web preview deploys (#5465)
Theo Browne963ebf5bd7cc
diff --git a/.github/workflows/web-preview.yml b/.github/workflows/web-preview.ymlnew file mode 100644index 000000000..f9cc3b063--- /dev/null+++ b/.github/workflows/web-preview.yml@@ -0,0 +1,132 @@+name: Web Preview++# Label a PR `preview:web` to get a hosted-web preview deployment on Vercel for+# that push and every subsequent push. The deployment is a plain (non-prod,+# non-aliased) deploy into the existing hosted-web Vercel project, so the+# latest/nightly channel aliases are never touched.+#+# The build intentionally omits the T3 Connect cloud config (Clerk keys, relay+# URL): previews boot as the hosted-static app with manual pairing only. Pair a+# server into a preview with `t3 pair --tailscale` (or any reachable HTTPS+# backend) and open the pairing URL against the preview origin.+#+# The preview must be opened at the exact deployment URL from the PR comment.+# Vite bakes that URL in as the hosted origin (via VERCEL_URL), and+# `isHostedStaticApp` matches on origin, so branch-alias URLs will not+# self-identify as the hosted app.++on:+ pull_request:+ types: [labeled, synchronize, reopened]++permissions:+ contents: read+ pull-requests: write++concurrency:+ group: web-preview-${{ github.event.pull_request.number }}+ cancel-in-progress: true++jobs:+ deploy:+ name: Deploy web preview+ # Same-repo PRs only: fork PRs do not receive the Vercel secrets, and this+ # workflow should skip rather than fail for them. On `labeled` events, only+ # the preview label itself triggers a deploy.+ if: >-+ github.event.pull_request.head.repo.full_name == github.repository &&+ contains(github.event.pull_request.labels.*.name, 'preview:web') &&+ (github.event.action != 'labeled' || github.event.label.name == 'preview:web')+ runs-on: blacksmith-8vcpu-ubuntu-2404+ timeout-minutes: 10+ env:+ VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}+ VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}+ VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}+ VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}+ steps:+ - name: Checkout+ uses: actions/checkout@v6+ with:+ ref: ${{ github.event.pull_request.head.sha }}+ sparse-checkout: |+ /*+ !/.repos/+ sparse-checkout-cone-mode: false++ - name: Setup Vite++ uses: voidzero-dev/setup-vp@v1+ with:+ node-version-file: package.json+ cache: true+ run-install: |+ args:+ - --filter=@t3tools/scripts...+ - --filter=@t3tools/web...++ - id: deploy+ name: Deploy preview+ shell: bash+ run: |+ set -euo pipefail++ if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" || -z "${VERCEL_PROJECT_ID:-}" ]]; then+ echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID." >&2+ exit 1+ fi++ vercel_scope="${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"++ deployment_url="$(+ vp dlx [email protected] deploy \+ --archive=tgz \+ --yes \+ --token "$VERCEL_TOKEN" \+ --scope "$vercel_scope"+ )"++ echo "Deployed $deployment_url"+ echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"++ - name: Comment deployment URL+ uses: actions/github-script@v8+ env:+ DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment_url }}+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}+ with:+ script: |+ const marker = "<!-- web-preview-deploy -->";+ const body = [+ marker,+ "### Web preview",+ "",+ `${process.env.DEPLOYMENT_URL} (for ${process.env.HEAD_SHA.slice(0, 7)})`,+ "",+ "Open this exact URL — the hosted-app origin is baked in at build time.",+ "Pair a server into it with `t3 pair --tailscale`, or paste a host + pairing",+ "code under Settings → Connections.",+ ].join("\n");++ const { data: comments } = await github.rest.issues.listComments({+ owner: context.repo.owner,+ repo: context.repo.repo,+ issue_number: context.payload.pull_request.number,+ per_page: 100,+ });+ const existing = comments.find((comment) => comment.body?.includes(marker));++ if (existing) {+ await github.rest.issues.updateComment({+ owner: context.repo.owner,+ repo: context.repo.repo,+ comment_id: existing.id,+ body,+ });+ } else {+ await github.rest.issues.createComment({+ owner: context.repo.owner,+ repo: context.repo.repo,+ issue_number: context.payload.pull_request.number,+ body,+ });+ }