File tree Expand file tree Collapse file tree 4 files changed +273
-216
lines changed
Expand file tree Collapse file tree 4 files changed +273
-216
lines changed Original file line number Diff line number Diff line change @@ -41,10 +41,28 @@ jobs:
4141 if : github.event.action != 'closed'
4242 run : " [[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
4343
44+ - name : Resolve preview URLs
45+ if : github.event.action != 'closed'
46+ id : preview-vars
47+ env :
48+ PREVIEW_SITE_URL : ${{ vars.PREVIEW_SITE_URL }}
49+ run : |
50+ repo_name="${GITHUB_REPOSITORY#*/}"
51+ base_url="${PREVIEW_SITE_URL:-https://${GITHUB_REPOSITORY_OWNER}.github.io/${repo_name}}"
52+ base_url="${base_url%/}"
53+ path_prefix="/pr-preview/pr-${{ github.event.pull_request.number }}"
54+
55+ echo "base_url=${base_url}" >> "$GITHUB_OUTPUT"
56+ echo "path_prefix=${path_prefix}" >> "$GITHUB_OUTPUT"
57+
4458 - name : Build PR preview
4559 if : github.event.action != 'closed'
60+ env :
61+ GATSBY_PREVIEW : " true"
62+ GATSBY_SITE_URL : ${{ steps.preview-vars.outputs.base_url }}
63+ PATH_PREFIX : ${{ steps.preview-vars.outputs.path_prefix }}
4664 run : |
47- npm run build
65+ npm run build:preview
4866
4967 # Block all crawlers from indexing PR previews.
5068 cat > public/robots.txt <<'EOF'
7290 message : |
7391 🚀 **Preview deployment for PR #${{ github.event.pull_request.number }}**
7492
75- 🌐 **Preview URL**: https:// ${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}/
93+ 🌐 **Preview URL**: ${{ steps.preview-vars.outputs.base_url }}/pr-preview/pr-${{ github.event.pull_request.number }}/
7694
7795 _This preview will be updated automatically when you push new commits to this PR._
7896
You can’t perform that action at this time.
0 commit comments