Skip to content

ci(previews): build, check, and preview every pull request - #21

Merged
zZebrahz merged 6 commits into
mainfrom
ci/pr-previews
Sep 20, 2026
Merged

zZebrahz merged 6 commits into
mainfrom
ci/pr-previews

Conversation

@zZebrahz

@zZebrahz zZebrahz commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

No workflow ran on pull requests. The only automation was a push-to-main deploy, so:

  • a broken internal documentation link could reach production unnoticed;
  • reviewers had to check out a branch and run bun run dev to see a content or design change.

The upcoming documentation work expects outside contributors, so review needs to be possible from the pull request itself.

Solution

Three workflows, split so that the job running contributor code never holds a secret.

Workflow Trigger Holds secrets Does
pr-build.yml pull_request No Builds the site, validates internal docs links, uploads dist as an artifact
preview-deploy.yml workflow_run Yes (Preview env) Uploads the artifact to Cloudflare Pages, comments the URL
preview-teardown.yml PR closed + weekly Yes (Preview env) Deletes that PR's deployments

Previews land at https://pr-<number>.temp-siloserver-org.pages.dev. The alias is repointed on every push, so the link in the comment always shows the latest build.

Preview builds render an orange banner linking back to the pull request and carry noindex, so a preview cannot be mistaken for the published site or compete with it in search. Production builds set none of the preview variables, so nothing changes on siloserver.org.

Cloudflare credentials live in the Preview GitHub environment rather than in repository secrets. Repository secrets are readable by any pull_request job on a same-repo branch, which would defeat the split; environment secrets are not.

Also included

  • The Starlight sidebar moves to src/data/sidebar.mjs, so adding a documentation page no longer means editing astro.config.mjs.
  • The docs edit link is corrected from silo-website to siloserver.org; it was only working through GitHub's rename redirect.
  • Link validation caught one existing broken link in installation.md (a trailing slash, which conflicts with trailingSlash: "never"). Fixed.

Validation

bun install --frozen-lockfile && bun run build

Passes with link validation enabled.

  • Preview build (PUBLIC_PREVIEW_* set): banner and noindex present on the homepage, a docs page, and a policy page; canonical and OpenGraph URLs resolve to the preview origin.
  • Production build: no banner, no robots tag on the same three pages.
  • Every env.PREVIEW_PROJECT reference was checked against GitHub's context-availability table; all sit in steps.*.env, steps.*.with, or steps.*.run, where the env context is valid.

Preview banner on a docs page at 390px:

preview-banner-docs-390

I could not capture a desktop-width screenshot: headless Chrome and Brave both refused 1440px captures on this machine, though 390px worked. The banner is a single full-width element, so the mobile capture shows its full styling.

Expected: no preview on this pull request

workflow_run triggers only fire once the workflow file exists on the default branch. On this PR, pr-build.yml will run and produce the artifact, but no preview will deploy and no comment will appear. The first real preview arrives on the next pull request opened after this merges. The deploy and teardown paths are therefore unexecuted in this change.

Before merging

  1. Mark the build job of "PR build" as a required status check on main.

The Cloudflare project (temp-siloserver-org, direct upload) and the Preview environment with CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID are already in place. The project name is set once per workflow as PREVIEW_PROJECT; when previews move to an organization-owned Cloudflare account, create the project there and update that value in the three files.


AI-assisted contribution. Written by Claude Opus 5 (claude-opus-5) running in Claude Code, at the maintainer's direction. Workflow deployment paths have not been executed; they require the Cloudflare project and secrets to be exercised by a real run.

No workflow ran on pull requests: the only automation was a push-to-main
deploy. Reviewers had to check out a branch to see a documentation change,
and a broken internal link could reach production unnoticed. The upcoming
documentation work expects outside contributors, so review needs to be
possible from the pull request itself.

Add three workflows. "PR build" runs on every pull request, builds the site,
and validates internal documentation links; it holds no secrets, so it is
safe for forks. It uploads the built site as an artifact. "Preview deploy"
picks that artifact up through workflow_run, uploads it to Cloudflare Pages
under a pr-<number> branch alias, and posts a single sticky comment with the
URL. "Preview teardown" deletes those deployments when the pull request
closes, with a weekly sweep for anything missed.

Preview builds render an orange banner linking back to the pull request and
carry noindex, so a preview cannot be mistaken for the published site or
compete with it in search. Production builds set none of the preview
variables, so nothing changes on siloserver.org.

Cloudflare credentials live in the Preview environment rather than in
repository secrets, which keeps them unreadable from the workflow that runs
contributor code.

Also move the Starlight sidebar into src/data/sidebar.mjs so adding a page no
longer means editing astro.config.mjs, and correct the documentation edit link
to the current repository name. Link validation caught one existing broken
link in installation.md, fixed here.

Preview deployment cannot run on this pull request: workflow_run triggers only
fire once the workflow file is on the default branch. The first preview will
appear on the next pull request opened after this merges.

Validation:
- bun install --frozen-lockfile && bun run build (passes, link validation on)
- Preview build with PUBLIC_PREVIEW_* set: banner and noindex present on the
  homepage, a docs page, and a policy page; canonical and OpenGraph URLs
  resolve to the preview origin
- Production build: no banner, no robots tag on the same three pages
- Screenshot of the preview banner at 390px width attached to the pull request

AI-assisted contribution. Written by Claude Opus 5 (claude-opus-5) running in Claude Code,
at the maintainer's direction. Workflow deployment paths have not been
executed; they require the Cloudflare project and secrets to be in place.
@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 107ea2dc-08ac-40fd-9d6c-995b2a6a793d


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-20T18:43:23.183886Z 80e5f12 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

GitHub rejected pr-build.yml outright: "This run likely failed because of a
workflow file issue", with no jobs created. The _headers step used a plain
scalar whose value contains "X-Robots-Tag: noindex", and YAML reads that inner
colon-space as a nested mapping inside a compact mapping, which is invalid.

Use a block scalar for the run value. Behaviour is unchanged.

Validated by parsing every workflow with a YAML 1.2 parser, including the
pre-existing deploy.yml as a known-good control. All four parse, and the
triggers resolve as intended.

AI-assisted contribution. Written by Claude Opus 5 (claude-opus-5) running in
Claude Code, at the maintainer's direction.
@greptile-apps

greptile-apps Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 0/5

This PR is not safe to merge until the privileged artifact boundary, teardown implementation, status permission, and per-PR deployment ordering are corrected.

Findings

  1. P1 Security Artifact metadata controls deployment ▶
  2. P1 Status permission is missing ▶
  3. P1 Teardown reads wrong fields ▶
  4. P1 Deployments can finish out-of-order ▶
  5. P2 Deployment listing is incomplete ▶
  6. P2 Security PR code receives credential ▶
  7. P2 Security Privileged dependencies are mutable ▶

Reviews (1) · Last reviewed commit: "ci(previews): build, check, and preview ..."

Comment thread .github/workflows/preview-deploy.yml Outdated
Comment thread .github/workflows/preview-deploy.yml
Comment thread .github/workflows/preview-teardown.yml Outdated
Comment thread .github/workflows/preview-teardown.yml Outdated
Comment thread .github/workflows/preview-deploy.yml
Comment thread .github/workflows/pr-build.yml
Comment thread .github/workflows/preview-deploy.yml Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bcf8a03384

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/preview-deploy.yml Outdated
Comment thread .github/workflows/preview-deploy.yml
Automated review of #21 found defects that would have made the preview
pipeline unsafe or simply non-functional. Each was verified against the
source before changing anything.

Artifact metadata no longer decides where a deployment lands. The privileged
workflow took the pull request number and commit from a file written by the
unprivileged build, which a fork can edit. A contributor could have replaced
another pull request's preview, overwritten its comment, and set a status on
an unrelated commit. Identity now comes from the trusted workflow_run event:
the head SHA from the payload, and the pull request resolved through the
GitHub API, requiring an open pull request whose head matches. Anything else
is skipped and the metadata artifact is gone.

Add statuses: write. The final step calls createCommitStatus, which is not
covered by contents: read or pull-requests: write, so every deploy would have
failed at the last step after already deploying and commenting.

Rewrite teardown against the Cloudflare REST API. The jq filters expected raw
fields, but `wrangler pages deployment list` renames them for display and
omits creation time, so the close path would have matched nothing and the
scheduled sweep would have failed under set -e. Previews would have
accumulated indefinitely. The API returns the raw records and is paginated
here, so the sweep is not limited to the most recent page.

Serialize deploys per source branch. Build concurrency does not order deploy
jobs that already started, so a slower older upload could land last and leave
the alias on stale content.

Drop GITHUB_TOKEN from the build step. It was added so preview client cards
would match production, but it handed a live credential to contributor-
controlled build code and broke the no-secrets boundary this design depends
on. Release lookups fall back to plain repository links in previews, which
never fails the build.

Pin the actions in the credential-bearing workflows to commit SHAs, and pin
the Wrangler version. This also fixes a reference to
marocchino/sticky-pull-request-comment@v2, a tag that does not exist; the
step would have failed. Pinned to v3.0.5.

Validated by parsing every workflow with a YAML 1.2 parser and exercising both
jq filters against sample API payloads, including a record with no branch
metadata. bun run build still passes.

AI-assisted contribution. Written by Claude Opus 5 (claude-opus-5) running in
Claude Code, at the maintainer's direction. The deploy and teardown paths
still have not executed; they require the workflows to be on the default
branch.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 779ad16820

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread README.md Outdated
Comment thread .github/workflows/preview-deploy.yml Outdated
Comment thread .github/workflows/preview-teardown.yml

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 445bd7270a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/preview-deploy.yml
@zZebrahz
zZebrahz merged commit d48e19e into main Sep 20, 2026
4 checks passed
@github-actions

Copy link
Copy Markdown

Preview removed after this pull request was closed.

This branch was successfully deployed

1 active deployment
Preview — 80e5f12e Deployed Sep 20, 2026 by zZebrahz via teardown #1
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