Skip to content

Removing Pr-Preview from netlify, moving to GitHub page#7595

Open
saurabhraghuvanshii wants to merge 15 commits intolayer5io:masterfrom
saurabhraghuvanshii:build
Open

Removing Pr-Preview from netlify, moving to GitHub page#7595
saurabhraghuvanshii wants to merge 15 commits intolayer5io:masterfrom
saurabhraghuvanshii:build

Conversation

@saurabhraghuvanshii
Copy link
Copy Markdown
Member

@saurabhraghuvanshii saurabhraghuvanshii commented Apr 8, 2026

Description

.github/workflows/build-and-deploy-site.yml

  • Uses a simple Gatsby build strategy:
    • Custom domain (PUBLIC_SITE_URL) → root build
    • GitHub Pages project repo → prefixed build (PATH_PREFIX=<repo>)
    • User/org repo → root build
  • Ensures .nojekyll is present
  • Writes public/CNAME from PUBLIC_SITE_URL host to prevent GitHub Pages from resetting the domain to *.github.io
  • Deploys to gh-pages with keep_files: true to preserve PR preview directories

.github/workflows/build-and-preview-site.yml

  • Builds preview on pull_request_target (opened, synchronize, reopened, closed)
  • Resolves preview base URL from:
    • PREVIEW_SITE_URL
    • fallback: PUBLIC_SITE_URL
    • fallback: GitHub Pages URL
  • Computes preview PATH_PREFIX correctly for:
    • Root custom domains → /pr-preview/pr-<n>
    • Path-based base URLs → /<base-path>/pr-preview/pr-<n>
    • GitHub Pages project repos → /<repo>/pr-preview/pr-<n>
  • Uses build:preview
  • Adds preview-only robots.txt (deny all)
  • Deploys with pr-preview-action
  • Comments preview URL on PR
  • Removes preview on PR close
  • Uses base-branch checkout for cleanup path to avoid worktree conflicts during removal

gatsby-config.js

  • Adds preview-aware and site-aware configuration:
    • isPreviewBuild
    • siteOrigin
    • pathPrefix
    • siteRootUrl
  • Sets:
    • siteMetadata.permalink
    • siteMetadata.siteUrl
      from runtime build inputs
  • Applies pathPrefix when provided
  • Skips sitemap/robots plugin generation for preview builds
  • Uses computed host/sitemap values for robots config in non-preview builds

src/components/seo.js

  • Adds preview detection
  • Adds noindex, nofollow meta tags for preview builds
  • Fixes:
    • Absolute URL generation for OG/Twitter images
    • Canonical URL handling
  • Avoids double-prefix URL generation in prefixed builds

package.json

  • Adds:
    • build:gh-pagesgatsby build --prefix-paths
    • build:previewGATSBY_PREVIEW=true gatsby build --prefix-paths

gatsby-node.js

  • Adds post-build diagnostics hook (onPostBuild)
  • Can export page graph/query output when:
    GATSBY_LOG_POSTBUILD_PAGES=true
    

This PR fixes #

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

@arjunmehta-git
Copy link
Copy Markdown

Thanks for taking this on, @saurabhraghuvanshii. Moving PR previews from Netlify to GitHub Pages is a meaningful infrastructure change that reduces our external dependency, and the workflow changes look structurally sound.

A few things to address before merge:

  • Empty description and issue reference — The PR body is still the template placeholder and "This PR fixes #" is blank. This is a significant workflow change that deserves a clear description of what's changing, why Netlify is being removed, and what the GitHub Pages preview URL pattern will look like for contributors.
  • Preview verification — Has the new GitHub Pages preview workflow been tested end-to-end on this branch? Specifically: does a commit to this PR trigger a deploy, and does the resulting preview URL work as expected? Broken PR previews would block the entire contributor review cycle.
  • Removal of preview-site.yml — Deleting the Netlify preview workflow means the l5io bot's preview comments ("🚀 Preview for commit...") will stop appearing. Confirm the GitHub Pages workflow produces an equivalent notification so contributors know where to find the preview.
  • Signed commits — The checkbox is checked, good.

The intent is right. Please flesh out the description and confirm the new workflow is functional.

@saurabhraghuvanshii saurabhraghuvanshii added the pr/hold Do not merge this PR label Apr 14, 2026
Copy link
Copy Markdown
Contributor

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

Note

Copilot was unable to run its full agentic suite in this review.

This PR migrates PR preview deployments from Netlify to GitHub Pages, adjusting Gatsby configuration and SEO behavior to support prefixed paths and prevent preview pages from being indexed.

Changes:

  • Add GitHub Pages–specific build scripts (with --prefix-paths) and a dedicated preview build mode (GATSBY_PREVIEW).
  • Update Gatsby siteUrl / pathPrefix handling and disable sitemap/robots plugins during preview builds.
  • Replace Netlify-based preview workflow with a GitHub Pages PR preview workflow (create/update on PR pushes; remove on PR close).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
src/components/seo.js Builds absolute meta URLs with prefixes and adds noindex for preview builds.
package.json Adds build scripts for GitHub Pages and preview builds using --prefix-paths.
gatsby-config.js Derives siteUrl/pathPrefix from env and disables sitemap/robots in preview builds.
.github/workflows/preview-site.yml Removes Netlify deployment workflow.
.github/workflows/build-and-preview-site.yml Builds + deploys PR previews to gh-pages and comments the preview URL.
.github/workflows/build-and-deploy-site.yml Deploys production site to gh-pages, handling project-pages vs org-pages pathing.

Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
Signed-off-by: Saurabh Singh <saurabhsraghuvanshi@gmail.com>
Signed-off-by: Saurabh Singh <saurabhsraghuvanshi@gmail.com>
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants