Skip to content

ci: deploy full-stack previews to the local-preview server - #14030

Merged
jmelahman merged 6 commits into
mainfrom
local-preview-deploy
Aug 21, 2026
Merged

ci: deploy full-stack previews to the local-preview server#14030
jmelahman merged 6 commits into
mainfrom
local-preview-deploy

Conversation

@jmelahman

@jmelahman jmelahman commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Adds a Deploy-Local-Preview job that builds web/ and uploads it to the self-hosted preview server, which runs the Next.js frontend and the FastAPI backend together per commit at <sha>-onyx.<preview-domain> (the domain comes from vars.PREVIEW_URL). The Vercel job is untouched — this one gives you a backend alongside the frontend, which Vercel previews cannot.

How it works

Only the frontend is uploaded. This workflow already builds it, and an uploaded side lands in the exact content-addressed slot the server's own build would have targeted, so the deploy skips rebuilding it. The backend is built server-side from the same commit.

That makes the build steps load-bearing: they have to match the server's manifest for this repo step for step, or the preview differs from what a rebuild would produce. Both now build @onyx-ai/shared before @onyx-ai/opal, since opal depends on it.

Worth flagging separately: the existing Vercel job below has those two in the opposite order. It works today only because bun install's prepare scripts have already built both — bun runs those for trusted workspaces. It is latent, not broken, so I left it alone rather than widen this PR.

Uploads authenticate with a GitHub Actions OIDC token bound to this repository and to the server's audience — hence id-token: write. No PAT and no session are involved; those gate the dashboard and the previews themselves, which require signing in as an onyx-dot-app member.

🤖 Generated with Claude Code


Summary by cubic

Deploys full‑stack previews via a new local-preview.yml so each commit gets a Next.js + FastAPI preview on the self‑hosted server from vars.PREVIEW_URL. Previously only Vercel frontend; now the backend runs with the frontend and backend‑only commits get previews.

  • Triggers on pushes to web/** and backend/** (excluding main) and supports manual workflow_dispatch; the Vercel workflow is unchanged and does not run for backend‑only commits.
  • Builds and uploads only the frontend; the server builds the backend from the same commit. Builds @onyx-ai/shared before @onyx-ai/opal and uploads a minimal .next/standalone tree with static assets.
  • Caches Bun install and Next.js incremental output; per‑branch concurrency prevents stale PR links when concurrent runs finish out of order.
  • Uses Actions OIDC (id-token: write) and comments the preview URL on the PR. vars.PREVIEW_URL selects the server; optional vars.PREVIEW_SSO_ORG only alters the sign‑in note; no server identity is hardcoded.
  • The preview server no longer watches this repo; this workflow is the sole source of previews. Set vars.PREVIEW_URL to enable.

Written for commit 38720ee. Summary will update on new commits.

Review in cubic

@jmelahman
jmelahman requested a review from a team as a code owner August 18, 2026 06:35
@greptile-apps

greptile-apps Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds a gated GitHub Actions job that builds the standalone web frontend, uploads it to the full-stack local-preview service using OIDC, deploys the matching commit, and posts the resulting URL to the source PR.

  • Installs pinned Bun, uv, and local-preview CLI versions.
  • Builds shared, Opal, and Next.js standalone artifacts in dependency order.
  • Uploads the frontend artifact and creates or updates a marked PR comment.

Confidence Score: 4/5

The PR appears safe to merge, with a non-blocking issue that can produce duplicate preview comments on heavily discussed pull requests.

The build and OIDC deployment path has no established blocking failure, while the unpaginated comment lookup can miss an older marker and post another status comment.

Files Needing Attention: .github/workflows/preview.yml

Important Files Changed

Filename Overview
.github/workflows/preview.yml Adds the full-stack preview deployment pipeline; the deployment flow is coherent, but existing-comment detection can create duplicates once the marker falls outside the first API page.

Sequence Diagram

sequenceDiagram
  participant G as GitHub push
  participant A as Actions runner
  participant P as Preview server
  participant R as Pull request
  G->>A: "Push to non-main branch touching web/**"
  A->>A: Install dependencies and build frontend
  A->>A: Assemble standalone upload tree
  A->>P: OIDC-authenticated upload and deploy
  P-->>A: Ready preview URL
  A->>R: Create or update preview comment
Loading
Prompt To Fix All With AI
### Issue 1
.github/workflows/preview.yml:133-134
**Paginate existing comment lookup**

When a pull request has more than the API's default page of comments and the deployment marker is on a later page, this lookup does not find it and posts another preview comment, leaving duplicate and potentially stale deployment links.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "ci: deploy full-stack previews to the lo..." | Re-trigger Greptile

Comment thread .github/workflows/preview.yml Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread .github/workflows/preview.yml Outdated
Comment thread .github/workflows/preview.yml Outdated
Comment thread .github/workflows/preview.yml Outdated
Comment thread .github/workflows/preview.yml Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread .github/workflows/local-preview.yml Outdated
@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Preview Deployment

Status Preview Commit Updated
https://onyx-preview-fh4i7h3n4-danswer.vercel.app 38720ee 2026-08-21 19:38:17 UTC

@github-actions

Copy link
Copy Markdown
Contributor

🖼️ Visual Regression Report

Project Changed Added Removed Unchanged Report
admin 4 0 0 183 View Report
exclusive 0 0 0 10 ✅ No changes

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Full-stack Preview (frontend + backend)

Status Preview Commit Updated
https://38720ee-onyx.preview.onyxcorp.dev/ 38720ee 2026-08-21 19:37:14 UTC

Sign in with GitHub as an onyx-dot-app member to view it.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread .github/workflows/local-preview.yml
@jmelahman
jmelahman force-pushed the local-preview-deploy branch from be4384a to bcb1371 Compare August 18, 2026 20:29
jmelahman and others added 6 commits August 21, 2026 10:29
Adds a job that builds web/ and uploads it to the self-hosted preview
server, which runs the Next.js frontend and the FastAPI backend together
per commit at <sha>-onyx.preview.onyxcorp.dev. The Vercel job is
untouched; this one deploys the backend alongside the frontend, which
Vercel previews cannot.

Only the frontend is uploaded. This workflow already builds it, and an
uploaded side lands in the exact content-addressed slot the server's own
build would have targeted, so the deploy skips rebuilding it. The backend
is built server-side from the same commit. The build steps therefore have
to match the server's manifest for this repo step for step — a divergence
is a preview that differs from what a rebuild would produce.

Uploads authenticate with a GitHub Actions OIDC token bound to this
repository and to the server's audience, hence id-token: write. No PAT and
no session are involved; those gate the dashboard and the previews
themselves, which require signing in as an onyx-dot-app member.

The job is gated on vars.PREVIEW_URL, so it stays dormant until that
variable is set on the repo.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The job already took its server from vars.PREVIEW_URL, but a comment named
the preview domain and the PR comment hardcoded the org the server admits.
Both are properties of the deployment, not of this repo's CI, so they move
to Actions variables managed in onyx-infra alongside PREVIEW_URL.

PREVIEW_SSO_ORG is optional: it feeds one clause of the sign-in line, and
the line drops that clause when it is unset. Pointing this workflow at a
different local-preview deployment is now a variable change rather than a
PR.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The local-preview job needs to fire on backend-only commits; the Vercel
job must not. Since `on:` is workflow-level, that split has to be two
files rather than two path filters.

The preview server no longer watches this repo (watch=false), so this
workflow is the only thing that creates a preview — which is the point:
CI builds the frontend on a GitHub runner and uploads it, instead of the
single preview host rebuilding every branch itself.

Deployment identity comes from the repo-level Actions variables
PREVIEW_URL and PREVIEW_SSO_ORG, managed in the github-org Terraform
workspace, so onyxcorp.dev is no longer hardcoded here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Path filters do not apply to workflow_dispatch, so this also covers a
commit that changed neither web/ nor backend/ but still wants a preview.
Only usable once this file reaches main — GitHub resolves dispatchable
workflows from the default branch.

Includes a throwaway file under web/ to trigger the path filter once, so
the upload path gets exercised before merge. Reverted in the next commit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The frontend build is 128s of this job's 140s, and every run compiled the
app from cold. Caching next build's incremental output is the lever;
caching bun's install cache matches what pr-storybook-build.yml already
does. Both are keyed so an unchanged tree restores exactly and a changed
one still starts from the last build.

Also drops the throwaway trigger file now that the pipeline has run
green end to end.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Replace the `A && B || C` public copy with an if block, so a missing
directory stays optional but a failed copy fails the job. actionlint
flagged the old form (SC2015).

Paginate the PR comment lookup: on a long PR the marker can sit past
the first page, which posts a duplicate comment.

Add a per-branch concurrency group so two commits deploying together
cannot finish out of order and leave a stale preview URL.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jmelahman
jmelahman force-pushed the local-preview-deploy branch from bcb1371 to 38720ee Compare August 21, 2026 19:34
@jmelahman
jmelahman added this pull request to the merge queue Aug 21, 2026
Merged via the queue into main with commit 4a8ed76 Aug 21, 2026
54 checks passed
@jmelahman
jmelahman deleted the local-preview-deploy branch August 21, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants