Skip to content

Commit 5fea282

Browse files
authored
Debugging Preview Function (#19)
* debugging preview * preview mechanism * testing preview comment * πŸ”„ Trigger empty push * πŸ”„ Trigger empty push * editing some i wanna edit, and plus i wanna trigger a preview * fixing navigation when in preview mode * reverting last attempt * testing * please work
1 parent 4f551b4 commit 5fea282

File tree

4 files changed

+45
-9
lines changed

4 files changed

+45
-9
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Cleanup Preview
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
jobs:
8+
delete-preview:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout gh-pages branch
13+
uses: actions/checkout@v3
14+
with:
15+
ref: gh-pages
16+
token: ${{ secrets.GITHUB_TOKEN }}
17+
18+
- name: Remove preview folder for PR
19+
run: |
20+
git config user.name "github-actions"
21+
git config user.email "github-actions@github.com"
22+
rm -rf previews/pr-${{ github.event.pull_request.number }}
23+
git add -A
24+
git commit -m "🧹 Remove preview for PR #${{ github.event.pull_request.number }}" || echo "Nothing to commit"
25+
git push origin gh-pages

β€Ž.github/workflows/preview.ymlβ€Ž

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Deploy Preview
33
on:
44
pull_request:
55
branches:
6-
- main # or the branch you want to base the preview on
6+
- main
77

88
jobs:
99
build-and-deploy:
@@ -13,29 +13,33 @@ jobs:
1313
- name: Checkout repository
1414
uses: actions/checkout@v3
1515

16-
- name: Set up Node.js 22
16+
- name: Set up Node.js
1717
uses: actions/setup-node@v3
1818
with:
19-
node-version: '22' # Specify the version of Node.js you need
19+
node-version: '22'
2020

21-
- name: Run install and export
21+
- name: Install and export
2222
run: |
2323
npm install
2424
npm run export
25+
env:
26+
WEBSITE_BASE_PATH: "/previews/pr-${{ github.event.pull_request.number }}"
2527

2628
- name: Deploy to GitHub Pages Preview
2729
uses: peaceiris/actions-gh-pages@v4
2830
with:
2931
github_token: ${{ secrets.GITHUB_TOKEN }}
3032
publish_dir: ./out
31-
publish_branch: gh-pages-preview-${{ github.event.pull_request.number }}
32-
cname: wiki.watonomous.ca
33+
publish_branch: gh-pages
34+
destination_dir: previews/pr-${{ github.event.pull_request.number }}
35+
force_orphan: false
3336

3437
- name: Comment on the PR with the preview link
35-
uses: peter-evans/commit-comment@v2
38+
uses: peter-evans/create-or-update-comment@v3
3639
with:
3740
token: ${{ secrets.GITHUB_TOKEN }}
41+
issue-number: ${{ github.event.pull_request.number }}
3842
body: |
3943
πŸš€ Preview of the changes is available at:
40-
https://${{ github.repository_owner }}.github.io/${{ github.repository }}/gh-pages-preview-${{ github.event.pull_request.number }}
41-
44+
https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/previews/pr-${{ github.event.pull_request.number }}
45+
edit-mode: replace

β€Žnext.config.jsβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ const withNextra = require("nextra")({
44
latex: true,
55
});
66

7+
const basePath = (process.env.WEBSITE_BASE_PATH || '').replace(/\/$/, '')
8+
79
module.exports = {
810
...withNextra(),
911
images: {
1012
unoptimized: true,
1113
},
14+
basePath,
15+
assetPrefix: basePath,
16+
trailingSlash: true,
1217
};

β€Žpages/about.mdxβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ We are an agile group of developers, engineers, businessmen, designers, and mark
2020

2121
## Our Goal and Values
2222

23+
WATonomous follows a singular goal:
24+
2325
import { Callout } from 'nextra/components'
2426

2527
<Callout>

0 commit comments

Comments
Β (0)