Skip to content

Add WebContainer-based branch preview deployments#5475

Open
dimitrieh wants to merge 2 commits intonode-red:masterfrom
dimitrieh:preview-deploy
Open

Add WebContainer-based branch preview deployments#5475
dimitrieh wants to merge 2 commits intonode-red:masterfrom
dimitrieh:preview-deploy

Conversation

@dimitrieh
Copy link
Contributor

@dimitrieh dimitrieh commented Feb 4, 2026

  • New feature (non-breaking change which adds functionality)

Proposed changes

Adds a GitHub Actions workflow that deploys live branch previews to Netlify. Each branch gets a URL where Node-RED boots and runs entirely in the browser using WebContainer. Deployments surface natively in the PR UI via GitHub's Deployments API — no bot comments.

How it works

  1. On push, the workflow snapshots the source using @webcontainer/snapshot
  2. Deploys a single-page HTML loader + snapshot to Netlify
  3. The loader boots a WebContainer in the browser, runs npm ci → build → start, and loads the Node-RED editor in an iframe
  4. The deploy URL is registered as a GitHub Deployment, visible in the PR merge box

The workflow triggers on every push, so each commit gets its own deployment. This could be scoped to only deploy the latest commit per branch, or per PR, depending on preference.

External dependencies

  • @webcontainer/api@1.6.1 loaded from unpkg CDN at runtime in the browser (https://unpkg.com/@webcontainer/api@1.6.1?module)
  • @webcontainer/snapshot installed during CI to generate the filesystem snapshot
  • netlify-cli installed during CI for deployment

Demo

CleanShot 2026-02-04 at 13 28 23

Working example on my fork:

Setup required

To enable this on the node-red org, two repository secrets are needed:

Secret Description
NETLIFY_AUTH_TOKEN API token from a Netlify account
NETLIFY_SITE_ID Target Netlify site ID

Branch URL structure

With the current Netlify CLI deploy approach:

  • master → Netlify site's production URL (site-name.netlify.app, or custom domain if configured)
  • branchesbranch-name--site-name.netlify.app

To use a custom Node-RED domain with per-branch subdomains (e.g., feature-x.preview.nodered.org), switch from CLI deploys to Netlify's Git-based branch deploy integration and add a wildcard DNS record (*.preview.nodered.org → Netlify).

Fork PR considerations

Workflows triggered by pull_request from forks don't have access to repository secrets. To support external contributor previews, either:

  • Use a pull_request_target trigger (runs with base repo secrets, requires security review)
  • Use a two-workflow approach (untrusted build → trusted deploy via artifact)
  • Limit previews to branches pushed directly to the repo

Checklist

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the forum/slack team.
  • I have run npm run test to verify the unit tests pass

Deploy branch previews to Netlify with a WebContainer-powered loader
that boots Node-RED in the browser. Includes GitHub deployment status
integration for PR visibility.
@dimitrieh
Copy link
Contributor Author

@knolleary please have a look here. This enabled deployment previews using webcontainers: https://preview-deploy--deft-genie-456e79.netlify.app/

All details to set this up right for this repo in the PR body. Also, no pollution of the repository by keeping everything in the GitHub workflow file.

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.

1 participant