Skip to content

Commit 0b12d43

Browse files
committed
(GH-74) Fix documentation website preview for pull requests
Closes #74
1 parent 6b891fb commit 0b12d43

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

.github/workflows/pull_request_docs_preview.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
name: "🦕 Docusaurus Documentation Website (PR Preview)"
1+
name: "🦕 Docusaurus Documentation Website (PR Preview)"
22

33
on:
4+
push:
5+
branches-ignore:
6+
- release-prep
47
pull_request:
58
branches:
69
- main
@@ -9,6 +12,9 @@ on:
912
- reopened
1013
- synchronize
1114
- closed
15+
paths:
16+
- 'website/**'
17+
- '.github/workflows/pull_request_docs_preview.yml'
1218

1319
permissions:
1420
contents: write
@@ -24,7 +30,7 @@ jobs:
2430
steps:
2531
- name: Checkout
2632
uses: actions/checkout@v6
27-
33+
2834
- name: Setup Node.js
2935
uses: actions/setup-node@v6
3036
with:
@@ -34,29 +40,29 @@ jobs:
3440

3541
- name: Install dependencies
3642
run: npm ci
37-
43+
3844
- name: Build website
3945
run: npm run build
4046
env:
41-
DOCUSAURUS_BASE_URL: /pr-preview/pr-${{ github.event.pull_request.number }}/
47+
PR_NUMBER: ${{ github.event.pull_request.number }}
4248

4349
- name: Deploy preview
4450
uses: rossjrw/pr-preview-action@v1
4551
with:
4652
source-dir: ./website/build/
47-
53+
4854
# - name: Comment PR
4955
# uses: actions/github-script@v7
5056
# with:
5157
# script: |
5258
# const url = `https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}/`;
5359
# const comment = `### 📖 Documentation Preview
54-
60+
5561
# The documentation preview for this PR is available at:
5662
# ${url}
57-
63+
5864
# This preview will be updated automatically when the PR is updated.`;
59-
65+
6066
# github.rest.issues.createComment({
6167
# issue_number: context.issue.number,
6268
# owner: context.repo.owner,

website/docusaurus.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import { themes as prismThemes } from "prism-react-renderer";
88

99
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
1010

11+
const BASE_URL =
12+
process.env.PR_NUMBER !== undefined
13+
? `/busly-cli/pr-preview/pr-${process.env.PR_NUMBER}/`
14+
: "/busly-cli";
15+
1116
/** @type {import('@docusaurus/types').Config} */
1217
const config = {
1318
title: "Busly CLI for NServiceBus",
@@ -21,7 +26,7 @@ const config = {
2126
url: "https://tragiccode.com",
2227
// Set the /<baseUrl>/ pathname under which your site is served
2328
// For GitHub pages deployment, it is often '/<projectName>/'
24-
baseUrl: "/busly-cli",
29+
baseUrl: BASE_URL,
2530

2631
// GitHub pages deployment config.
2732
// If you aren't using GitHub pages, you don't need these.

0 commit comments

Comments
 (0)