From b0f3de0ab9637f0241778a30d0ffb23e8582b0eb Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 28 Sep 2026 23:10:07 +0000 Subject: [PATCH] Build PR previews with site.url set to the preview URL Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01RBeXFA4VVU7vGuBVLRcPbZ --- .github/workflows/main.yml | 13 ++++++++++++- README-DEPLOYMENT.md | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e088b872..4a271789 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,12 +43,23 @@ jobs: ruby-version: 3.3.4 bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Build Jekyll website + env: + EVENT_NAME: ${{ github.event_name }} + PR_NUMBER: ${{ github.event.pull_request.number }} run: | set -xo pipefail rm -rf _site/* gem install bundler -v 2.6.3 bundle install - bundle exec jekyll build + config=_config.yml + if [ "$EVENT_NAME" = "pull_request" ]; then + # Absolute links (site.url) must point at the preview deployment, + # not at the production site. The alias matches the + # --branch=pr- used by the preview job. + echo "url: https://pr-${PR_NUMBER}.aeamain.pages.dev" > "$RUNNER_TEMP/_config_preview.yml" + config="$config,$RUNNER_TEMP/_config_preview.yml" + fi + bundle exec jekyll build --config "$config" - name: Generate agent instruction file run: python3 .github/scripts/generate_agent_md.py - name: Upload site artifact diff --git a/README-DEPLOYMENT.md b/README-DEPLOYMENT.md index f26098f8..16534e8c 100644 --- a/README-DEPLOYMENT.md +++ b/README-DEPLOYMENT.md @@ -80,6 +80,7 @@ Once the secrets exist, every PR from a repo branch (not a fork) will get: - A live preview at a Cloudflare Pages URL specific to that PR (`--branch=pr-`), rebuilt on every push to the PR. +- A site built with `url` set to that preview URL, so absolute links stay on the preview instead of pointing at production - A PR comment with the preview link, edited in place on each new commit rather than re-posted.