Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(deploy): include repo name in sandbox base path for GitHub Pages (#3237)

Cindy Zhang8650503d6978
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c420927468..874872a8db 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -231,6 +231,7 @@ jobs:
echo "short_hash=${SHORT_HASH}" >> $GITHUB_OUTPUT
echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
+ echo "sandbox_base_path=/${REPO_NAME}/pr/${PR_NUMBER}/sandbox" >> $GITHUB_OUTPUT
echo "storybook_url=https://${REPO_OWNER}.github.io/${REPO_NAME}/pr/${PR_NUMBER}/" >> $GITHUB_OUTPUT
echo "sandbox_url=https://${REPO_OWNER}.github.io/${REPO_NAME}/pr/${PR_NUMBER}/sandbox/" >> $GITHUB_OUTPUT
@@ -238,7 +239,10 @@ jobs:
if: needs.check-scope.outputs.docsite_only != 'true' && github.event_name == 'pull_request'
run: pnpm -F @astryxdesign/sandbox build
env:
- SANDBOX_BASE_PATH: /pr/${{ steps.urls.outputs.pr_number }}/sandbox
+ # Must match the deployed Pages path (<owner>.github.io/<repo>/pr/<n>/sandbox).
+ # Built without the /<repo> prefix, the sandbox's root-absolute asset URLs
+ # drop that segment and 404 — breaking all styles/JS on the preview.
+ SANDBOX_BASE_PATH: ${{ steps.urls.outputs.sandbox_base_path }}
NODE_OPTIONS: '--max-old-space-size=8192'
- name: Upload Storybook artifact
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 8f37c2487d..c4bbf293a3 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -138,7 +138,11 @@ jobs:
- name: Build Sandbox
run: pnpm -F @astryxdesign/sandbox build
env:
- SANDBOX_BASE_PATH: /sandbox
+ # GitHub Pages serves this project at <owner>.github.io/<repo>/, so the
+ # sandbox must be built with the repo name as a base path prefix —
+ # otherwise its root-absolute asset URLs (/sandbox/_next/...) drop the
+ # /<repo> segment and 404. Derived from the repo name so it survives renames.
+ SANDBOX_BASE_PATH: /${{ github.event.repository.name }}/sandbox
NODE_OPTIONS: '--max-old-space-size=4096'
- name: Preserve PR previews and reports from gh-pages
@@ -173,7 +177,7 @@ jobs:
mkdir -p deploy/storybook
cp -r apps/storybook/dist/* deploy/storybook/
- # Stable sandbox (built with basePath=/sandbox)
+ # Stable sandbox (built with basePath=/<repo>/sandbox)
if [ -d "apps/sandbox/out" ]; then
mkdir -p deploy/sandbox
cp -r apps/sandbox/out/* deploy/sandbox/
diff --git a/.github/workflows/redeploy-preview.yml b/.github/workflows/redeploy-preview.yml
index c4bee0a220..08ac7211db 100644
--- a/.github/workflows/redeploy-preview.yml
+++ b/.github/workflows/redeploy-preview.yml
@@ -67,7 +67,10 @@ jobs:
- name: Build Sandbox
env:
- SANDBOX_BASE_PATH: /pr/${{ github.event.inputs.pr_number }}/sandbox
+ # GitHub Pages serves at <owner>.github.io/<repo>/, so the sandbox base
+ # path must include the repo name — otherwise root-absolute asset URLs
+ # drop the /<repo> segment and 404, breaking the preview's styles/JS.
+ SANDBOX_BASE_PATH: /${{ github.event.repository.name }}/pr/${{ github.event.inputs.pr_number }}/sandbox
run: pnpm -F @astryxdesign/sandbox build
- name: Deploy to GitHub Pages