Library / Code, Git & Developer Tools
Code, Git & Developer Tools
Post PR preview page screenshots to GitHub pull requests with Snapshot Site
When an API call/webhook arrives, it automates developer work using GitHub, Snapshot Site.
What it does
## Screenshot PR Preview Pages → GitHub PR Comment ### How it works Your CI job calls this workflow's webhook once a pull-request preview deployment is live, POSTing owner, repository, prNumber, the preview base URL and — the important part — a pages array holding only the routes the pull request actually touched (built from git diff --name-only). A Code node joins each path onto previewUrl (handling a trailing slash on the base and a leading slash on the path without producing //), rejects any URL that is missing its https:// scheme, drops duplicate routes and caps the run at maxPages (10 by default). A single 30-second Wait lets the preview deployment warm up, then the loop takes one page per iteration through a Snapshot Site Screenshot call — WebP, 1280px wide, full page, cookie banners hidden — and records one row per page (label, URL, returned image link, ok / failed). Hard failures (network/HTTP after 3 retries) and soft failures (HTTP 200 + {error: true}) both land on the same recorder marked failed, and the loop keeps going. When the loop finishes, one Code node renders every row into a single GitHub-flavoured markdown body — a summary table, one collapsible embedded screenshot per captured page, and a clearly separated "could not be captured" block — and the GitHub node posts it as one comment on the pull request. ### Setup steps - Install the n8n-nodes-snapshot-site community node (Settings → Community nodes → Install → n8n-nodes-snapshot-site) — verified by n8n. - Add a Snapshot Site credential and a GitHub credential (classic PAT with repo, or a fine-grained token with Pull requests: Read and write on the target repo). - owner, repository and issueNumber on the GitHub node are all driven by the webhook payload, so one workflow serves every repo that calls it — nothing to hardcode. - Activate the workflow and copy the Webhook node's Production URL (the Test URL only listens while the editor is open). - Call it from your preview-deploy job with {"owner":"your-org","repository":"your-repo","prNumber":123,"previewUrl":"https://pr-123.preview.example.com","commit":"a1b2c3d","maxPages":10,"pages":[{"path":"/","label":"Home"},{"path":"/pricing","label":"Pricing"}]}. - Build pages from the PR's diff, not from a static list — the README has a copy-pasteable GitHub Actions step that maps git diff --name-only to routes. Skip the call entirely when the diff
The steps
- When a Pull Request Preview Is Ready
- Build Preview Page List
- Wait for Preview to Settle
- Loop Over Changed Pages
- Capture Preview Page
- Check for API Error
- Record Page Capture
- Record Failed Capture
- Build PR Comment
- Post Preview Screenshots on the PR
Similar automations
Monitoring, Ops & IncidentsCatch soft 404 and error pages from sitemaps with Snapshot Site, Slack, and Google Sheets14 stepsData Sync & ETLAudit website readability weekly with Snapshot Site, Google Sheets, and Slack10 stepsMonitoring, Ops & IncidentsMonitor website uptime and visual drift with Snapshot Site, Google Sheets and Slack18 stepsData Sync & ETLSend nightly staging vs production drift digest from Google Sheets with Snapshot Site and12 steps