From 157c8a71c1e5e1e8345c8db612b146a9ec85cca3 Mon Sep 17 00:00:00 2001 From: Nils Schimmelmann Date: Sat, 9 May 2026 21:50:47 -0500 Subject: [PATCH] fix: use github.io base path for PR preview deployment URLs Replace CNAME-reading logic with configure-pages base_path so PR preview "View Deployment" links correctly point to /pr-N/ for both the main org (which GitHub auto-redirects to the custom domain) and forked repos. --- .github/workflows/deploy.yml | 17 +++-------------- .github/workflows/pr-preview.yml | 8 ++------ 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4c25032..6744385 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -187,22 +187,11 @@ jobs: const owner = context.repo.owner; const repo = context.repo.repo; - let baseUrlPath = process.env.BASE_URL_PATH; + const baseUrlPath = process.env.BASE_URL_PATH; let base = `https://${owner}.github.io`; - - const cnamePath = 'CNAME'; - if (fs.existsSync(cnamePath) && owner === 'mume') { - const domain = fs.readFileSync(cnamePath, 'utf8').trim(); - if (domain) { - base = `https://${domain}`; - } - } else { - const repo = context.repo.repo; - if (repo !== `${owner}.github.io`) { - base = `${base}/${repo}`; - } - } + const normalizedPath = baseUrlPath.startsWith('/') ? baseUrlPath : `/${baseUrlPath}`; + base = `${base}${normalizedPath}`.replace(/\/$/, ''); const url = `${base}/pr-${pr.number}/`; console.log(`Deployment URL for PR #${pr.number}: ${url}`); diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index c8527b2..ddc1fbb 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -29,16 +29,12 @@ jobs: - name: Determine Base URL Prefix id: base_url run: | - if [ -f CNAME ] && [ "${{ github.repository_owner }}" = "mume" ]; then + if [ "${{ github.event.repository.name }}" = "${{ github.repository_owner }}.github.io" ]; then echo "prefix=/" >> $GITHUB_OUTPUT - echo "host=$(cat CNAME)" >> $GITHUB_OUTPUT - elif [ "${{ github.event.repository.name }}" = "${{ github.repository_owner }}.github.io" ]; then - echo "prefix=/" >> $GITHUB_OUTPUT - echo "host=${{ github.repository_owner }}.github.io" >> $GITHUB_OUTPUT else echo "prefix=/${{ github.event.repository.name }}/" >> $GITHUB_OUTPUT - echo "host=${{ github.repository_owner }}.github.io" >> $GITHUB_OUTPUT fi + echo "host=${{ github.repository_owner }}.github.io" >> $GITHUB_OUTPUT - name: Setup environment run: ./scripts/ci-env.sh