Skip to content

Conversation

@heskew
Copy link
Member

@heskew heskew commented Sep 29, 2025

example use:

npm run preview:pr 319

example cli output. serve should open docs in a browser
image

@heskew heskew marked this pull request as ready for review September 29, 2025 23:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds functionality to preview Pull Request build artifacts locally by downloading and serving GitHub Pages build artifacts from GitHub Actions. The script provides security warnings and confirmation prompts since it executes potentially untrusted JavaScript from PR builds.

Key changes:

  • Adds a new preview:pr npm script that accepts a PR number as argument
  • Implements comprehensive security measures including argument sanitization and user confirmation prompts
  • Downloads, extracts, and serves GitHub Pages artifacts from successful workflow runs

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
scripts/preview-pr.mjs New script that fetches PR build artifacts, validates security, and serves them locally
package.json Adds preview:pr npm script entry point

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@Ethan-Arrowood Ethan-Arrowood left a comment

Choose a reason for hiding this comment

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

I think this is a great starting point but it does require the user having gh, unzip, and tar on their machine. We could reasonably replace all of those with npm modules. But that can happen later.

try {
// Get the PR's branch name and author info
const prInfo = JSON.parse(
execSync(`gh pr view ${PR_NUMBER} --json headRefName,author,title,url,isDraft`, { encoding: 'utf-8' })
Copy link
Member

Choose a reason for hiding this comment

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

What happens if user doesn't have gh cli tool?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, doesn't work without the tools. just a quick simple start. wouldn't take a whole lot to at least remove the gh cli dependency. unzip and tar are probably fine to kick down the road?

@Ethan-Arrowood Ethan-Arrowood merged commit 9a4dbef into main Sep 30, 2025
5 checks passed
@Ethan-Arrowood Ethan-Arrowood deleted the preview-pr branch September 30, 2025 17:13
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.

3 participants