Skip to content

Commit 8427b45

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

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

.github/workflows/pull_request_docs_preview.yml

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

33
on:
44
pull_request:
@@ -9,6 +9,9 @@ on:
99
- reopened
1010
- synchronize
1111
- closed
12+
paths:
13+
- 'website/**'
14+
- '.github/workflows/pull_request_docs_preview.yml'
1215

1316
permissions:
1417
contents: write
@@ -20,11 +23,12 @@ defaults:
2023

2124
jobs:
2225
deploy-preview:
26+
if: github.event.pull_request.head.ref != 'release-prep'
2327
runs-on: ubuntu-latest
2428
steps:
2529
- name: Checkout
2630
uses: actions/checkout@v6
27-
31+
2832
- name: Setup Node.js
2933
uses: actions/setup-node@v6
3034
with:
@@ -34,29 +38,29 @@ jobs:
3438

3539
- name: Install dependencies
3640
run: npm ci
37-
41+
3842
- name: Build website
3943
run: npm run build
4044
env:
41-
DOCUSAURUS_BASE_URL: /pr-preview/pr-${{ github.event.pull_request.number }}/
45+
PR_NUMBER: ${{ github.event.pull_request.number }}
4246

4347
- name: Deploy preview
4448
uses: rossjrw/pr-preview-action@v1
4549
with:
4650
source-dir: ./website/build/
47-
51+
4852
# - name: Comment PR
4953
# uses: actions/github-script@v7
5054
# with:
5155
# script: |
5256
# const url = `https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}/`;
5357
# const comment = `### 📖 Documentation Preview
54-
58+
5559
# The documentation preview for this PR is available at:
5660
# ${url}
57-
61+
5862
# This preview will be updated automatically when the PR is updated.`;
59-
63+
6064
# github.rest.issues.createComment({
6165
# issue_number: context.issue.number,
6266
# owner: context.repo.owner,

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Release
22

33
on:
44
workflow_dispatch: {}
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- CHANGELOG.md
510

611
permissions:
712
contents: write

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)