Repository navigation
ci: deploy netlify previews for stacked docs prs - #2851
Merged
Merged
Conversation
Netlify builds Deploy Previews only for PRs against branches it deploys (main, next, the archived vcluster-v* and platform-v* branches). Stacked PRs such as #2846 got no preview, so reviewers could not see rendered pages until the base merged, unless someone with Netlify access ran the manual CLI deploy from bc38bfd after every push. The new workflow builds any other same-repo PR with netlify build, so it uses netlify.toml's command and environment, uploads a draft at the alias pr-<number>, and upserts the URL through sticky-pr-comment. It never passes --prod. The deploy script rejects anything but a positive integer PR number, so the alias cannot take a deployed branch's subdomain. A missing NETLIFY_AUTH_TOKEN fails the job rather than passing green with nothing deployed. Closes DEVOPS-1556
✅ Deploy Preview for vcluster-docs-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
Job-level env exposed NETLIFY_AUTH_TOKEN to npm ci, so any dependency's install script could read it. Only the token check, netlify build and the deploy step need it.
Piotr1215
force-pushed
the
devops-1556/stacked-pr-previews
branch
from
September 28, 2026 08:22
a7c0e2d to
18e5c76
Compare
The first stacked preview run (#2852) failed at deploy: netlify-cli 27 errors with '--context flag is only available when using the --build flag'. The bats stub accepted any flags, so the suite missed it. The build step already applies the deploy-preview context.
No repo secret NETLIFY_AUTH_TOKEN exists. The org secret NETLIFY_ACCESS_TOKEN deployed a working draft on #2852 (run 36397634809), so reuse it instead of minting and rotating a new credential. The CLI still reads it as NETLIFY_AUTH_TOKEN.
Native GitHub stacks based on main, such as #2819 and #2820, already get Netlify Deploy Previews: the API reports their stack.base.ref as main. Branch-on-branch stacks like #2846 have no stack field and get none. branches-ignore only sees the immediate base, so the workflow would have built a duplicate preview for native stacks. A check job now reads stack.base.ref and skips them. The comment now uses the table layout of Netlify's own preview comment and links the deploy log, so both previews read the same way.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Content Description
Stacked docs PRs get no Netlify Deploy Preview, because Netlify only builds previews for PRs against branches it deploys. This adds a workflow that builds those PRs and deploys a Netlify draft at
pr-<number>, then posts the URL as a sticky PR comment that updates on every push.Key Changes
.github/workflows/stacked-pr-preview.yml: runs onpull_request(opened, synchronize, reopened) when the base is notmain,next,vcluster-v*, orplatform-v*. Those are the branches Netlify already deploys (read from the site'sallowed_branches). Runsnetlify build --context deploy-preview, so the build uses thenetlify.tomlcommand and environment, then deploys and comments withloft-sh/github-actionssticky-pr-comment/v1, using the same table layout as Netlify's own preview comment. Skips fork PRs. Fails if the token secret is missing.hack/preview/needs-stacked-preview.sh+ bats suite: acheckjob skips PRs in a native GitHub stack (gh stack) based onmain. Netlify already previews those: docs(tenants): make room for the Tenant primitive in existing prose #2819 and docs(tenants): link the Tenant boundary from the pages it gates #2820 reportstack.base.ref=mainand have Netlify previews, while branch-on-branch stacks such as docs: document network environment creation, allowlists, and endpoint change #2846, docs: unify navigation across docs sections #2839 and docs: draw the three instance outcomes and align the architecture diagrams #2808 have nostackfield and get none.hack/preview/deploy-stacked-preview.sh+ bats suite: runsnetlify deploy --no-build --json --context deploy-preview --alias pr-<N>, never--prod. It rejects any PR number that isn't a positive integer, so the alias can't match a deployed branch name..github/workflows/test-preview-scripts.yml: shellcheck and bats for the script on PRs tomain.CONTRIBUTING.md"Preview a stacked PR": describes the automation and keeps the manual CLI steps as a fallback..github/workflows/README.md: workflow entry and the secret it reads.Production and
nextdeploys are unchanged: no Netlify setting ornetlify.tomlchange, and draft deploys only.sticky-pr-commentis referenced by its action tag, following the loft-sh convention for internal actions. zizmor flags it asunpinned-uses, which is expected. Other workflows here pin internal actions by SHA; say if you want this one to match.Dependencies
None. The workflow reuses the existing org secret
NETLIFY_ACCESS_TOKEN, which is proven to deployvcluster-docs-sitedrafts. The site ID is in the workflow, since it grants no access.TODO
Preview Link
No rendered pages change.
CONTRIBUTING.mdand the workflows README aren't part of the site, so review the diff.Internal Reference
Closes DEVOPS-1556
AI review: mention
@claudein a comment to request a review or changes. See CONTRIBUTING.md for available commands.@netlify /docs