-
Notifications
You must be signed in to change notification settings - Fork 9
preview pr locally #328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
preview pr locally #328
Conversation
There was a problem hiding this 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:prnpm 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.
Ethan-Arrowood
left a comment
There was a problem hiding this 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' }) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
example use:
npm run preview:pr 319example cli output. serve should open docs in a browser
