Add static PR previews #391
Draft
NickVolynkin wants to merge 1 commit into
Draft
Conversation
Reviewing a docs PR currently means running the contributor's markdown locally with archbee dev, which executes untrusted content in the reviewer's browser (#340). This adds an automated preview instead: * tools/preview/snapshot.mjs renders every page of the archbee dev server in headless Chrome and saves a static, script-free copy. There is no static-export command in the Archbee CLI and fetching pages plainly returns an empty SPA shell, so a real browser does the rendering. All script tags and inline handlers are stripped and all root-absolute URLs are rewritten relative, so the snapshot can be served from any subpath and carries no executable JS from the PR. * docs-preview-build.yml (pull_request) builds that snapshot with a read-only token and uploads it as an artifact. It never sees secrets, which is what makes it safe to run on fork PRs. * docs-preview-deploy.yml (workflow_run) runs trusted code only, validates the artifact's PR number against the API, publishes the snapshot to gh-pages under pr/<n>/, and maintains a sticky PR comment with the preview link. * docs-preview-cleanup.yml (pull_request_target, closed) deletes pr/<n>/ from gh-pages. It never checks out PR code, which is the one condition under which pull_request_target is safe. Maintainers need to enable Pages once: deploy from branch, gh-pages, root. The gh-pages branch is created on first deploy.
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.
Work in progress: testing and adapting #357 to our workflows.