Skip to content

Commit d9afdf9

Browse files
Setup pushpreview.yml (#20)
* Setup pushpreview.yml * Fix wrong path * Improve workflow (prevent waste of resources) * Add name to workflows * Dynamically adapt to different environments, particularly for preview deployments
1 parent a8af227 commit d9afdf9

4 files changed

Lines changed: 49 additions & 3 deletions

File tree

.github/workflows/build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
name: Build and check
2+
13
on:
24
pull_request:
35

46
permissions:
57
contents: read
68

9+
concurrency:
10+
group: 'build-doc-${{ github.ref }}' # This ensures concurrency for the same branch or PR
11+
cancel-in-progress: true # This cancels any in-progress execution when a new commit is done on the same branch
12+
713
jobs:
814
build-doc:
915
name: Build documentation
@@ -17,4 +23,4 @@ jobs:
1723
run: yarn install --frozen-lockfile
1824
- name: Build documentation website
1925
# Check URLs are valid, path to images, etc.
20-
run: cd docs && yarn build
26+
run: yarn build

.github/workflows/deploy.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Deploy
2+
13
on:
24
push:
35
branches:
@@ -34,4 +36,4 @@ jobs:
3436
# The GH actions bot is used by default if you didn't specify the two fields.
3537
# You can swap them out with your own user credentials.
3638
user_name: github-actions[bot]
37-
user_email: 41898282+github-actions[bot]@users.noreply.github.com
39+
user_email: 41898282+github-actions[bot]@users.noreply.github.com

.github/workflows/pushpreview.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# When a PR get labelled "preview", deploy a web rendering of the changes via pushpreview
2+
name: PushPreview
3+
4+
on:
5+
pull_request_target:
6+
types:
7+
- labeled
8+
9+
jobs:
10+
preview:
11+
runs-on: ubuntu-24.04
12+
if: github.event.label.name == 'preview'
13+
steps:
14+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
15+
- name: Comment
16+
run: |
17+
gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body "⚙️ Hang tight! PushPreview is currently building your preview. We'll share the URL as soon as it's ready."
18+
env:
19+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
21+
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
22+
with:
23+
node-version: 18
24+
25+
- name: Set BASE_URL
26+
run: echo "BASE_URL=/github/${{ github.repository }}/${{ github.event.number }}/" >> $GITHUB_ENV
27+
28+
- name: Build site
29+
run: |
30+
yarn install --frozen-lockfile
31+
yarn build
32+
33+
- name: Generate preview
34+
uses: TechDocsStudio/pushpreview-action@cf958f7be2bf55d3f56d351bb9abf56b4c6b9a50 # 1.0.6
35+
with:
36+
source-directory: ./build
37+
github-token: ${{ secrets.GITHUB_TOKEN }}
38+
pushpreview-token: ${{ secrets.PUSHPREVIEW_TOKEN }}

docusaurus.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const config: Config = {
1313
url: 'https://nspanelmanager.com',
1414
// Set the /<baseUrl>/ pathname under which your site is served
1515
// For GitHub pages deployment, it is often '/<projectName>/'
16-
baseUrl: '/',
16+
baseUrl: process.env.BASE_URL || '/',
1717

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

0 commit comments

Comments
 (0)