Skip to content

Commit e8324df

Browse files
authored
Merge pull request #2 from MoX678/test-trigger-preview
Test trigger preview
2 parents a17f1f6 + 4c53aaa commit e8324df

File tree

2 files changed

+83
-106
lines changed

2 files changed

+83
-106
lines changed

.github/workflows/build_preview.yml

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,47 @@ permissions:
1313
id-token: write
1414
pull-requests: write
1515

16-
1716
jobs:
1817
build:
1918
if: github.event.action != 'closed'
2019
runs-on: ubuntu-latest
2120

2221
steps:
23-
- name: Checkout repository
22+
- name: Checkout PR branch
2423
uses: actions/checkout@v4
24+
with:
25+
ref: ${{ github.head_ref }}
2526

2627
- name: Setup Node.js
2728
uses: actions/setup-node@v4
2829
with:
2930
node-version: 18
3031

31-
- name: Cache npm dependencies
32-
uses: actions/cache@v4
33-
with:
34-
path: ~/.npm
35-
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
36-
restore-keys: |
37-
${{ runner.os }}-npm-
38-
3932
- name: Install dependencies
4033
run: npm ci
34+
35+
- name: Inject correct baseUrl into docusaurus.config.js
36+
id: inject
37+
run: |
38+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
39+
BASE_URL="/${{ github.event.repository.name }}/pr-${{ github.event.number }}/"
40+
else
41+
BASE_URL="/${{ github.event.repository.name }}/"
42+
fi
43+
44+
echo "Using baseUrl=$BASE_URL"
45+
echo "baseUrl=$BASE_URL" >> $GITHUB_OUTPUT
46+
47+
sed -i "s|baseUrl: '.*'|baseUrl: '$BASE_URL'|" docusaurus.config.js
48+
49+
- name: Comment injected baseUrl on PR
50+
if: github.event_name == 'pull_request'
51+
uses: marocchino/sticky-pull-request-comment@v2
52+
with:
53+
header: docusaurus-baseurl
54+
message: |
55+
🛠 **Injected baseUrl**
56+
➤ `${{ steps.inject.outputs.baseUrl }}`
4157
4258
- name: Build Docusaurus site
4359
run: npm run build
@@ -54,9 +70,6 @@ jobs:
5470
runs-on: ubuntu-latest
5571

5672
steps:
57-
- name: Checkout repository
58-
uses: actions/checkout@v4
59-
6073
- name: Download build artifact
6174
uses: actions/download-artifact@v4
6275
with:
@@ -67,10 +80,10 @@ jobs:
6780
id: vars
6881
run: |
6982
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
70-
echo "branch=pr-${{ github.event.number }}" >> $GITHUB_OUTPUT
83+
echo "destination_dir=pr-${{ github.event.number }}" >> $GITHUB_OUTPUT
7184
echo "url=https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ github.event.number }}/" >> $GITHUB_OUTPUT
7285
else
73-
echo "branch=gh-pages" >> $GITHUB_OUTPUT
86+
echo "destination_dir=." >> $GITHUB_OUTPUT
7487
echo "url=https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/" >> $GITHUB_OUTPUT
7588
fi
7689
@@ -79,7 +92,9 @@ jobs:
7992
with:
8093
github_token: ${{ secrets.GITHUB_TOKEN }}
8194
publish_dir: ./build
82-
publish_branch: ${{ steps.vars.outputs.branch }}
95+
publish_branch: gh-pages
96+
destination_dir: ${{ steps.vars.outputs.destination_dir }}
97+
keep_files: true # Keep other PR previews intact
8398

8499
- name: Comment preview link on PR
85100
if: github.event_name == 'pull_request'
@@ -95,10 +110,20 @@ jobs:
95110
runs-on: ubuntu-latest
96111

97112
steps:
98-
- name: Delete preview branch
99-
uses: dawidd6/action-delete-branch@v3
113+
- name: Checkout gh-pages
114+
uses: actions/checkout@v4
100115
with:
101-
github_token: ${{ secrets.GITHUB_TOKEN }}
102-
branches: pr-${{ github.event.pull_request.number }}
103-
soft_fail: true
104-
116+
ref: gh-pages
117+
118+
- name: Remove PR preview directory
119+
run: |
120+
git config user.name "github-actions[bot]"
121+
git config user.email "github-actions[bot]@users.noreply.github.com"
122+
123+
if [ -d "pr-${{ github.event.pull_request.number }}" ]; then
124+
git rm -rf pr-${{ github.event.pull_request.number }}
125+
git commit -m "🧹 Remove preview for PR #${{ github.event.pull_request.number }}"
126+
git push
127+
else
128+
echo "Directory pr-${{ github.event.pull_request.number }} not found, skipping cleanup"
129+
fi

docusaurus.config.js

Lines changed: 36 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,25 @@
66

77
import { themes as prismThemes } from "prism-react-renderer";
88

9-
const { themes } = require("prism-react-renderer");
109
/** @type {import('@docusaurus/types').Config} */
1110
const config = {
12-
title: 'MetaCall Tutorial',
11+
title: 'MetaCall Getting Started',
1312
tagline: 'Documentation for MetaCall',
1413
favicon: 'img/metacall-logo.png',
15-
organizationName: "MetaCall",
1614

1715
// Set the production url of your site here
18-
url: 'https://github.com',
16+
url: 'https://mox678.github.io',
1917
// Set the /<baseUrl>/ pathname under which your site is served
20-
// For GitHub pages deployment, it is often '/<projectName>/'
2118
baseUrl: '/docs2/',
2219

2320
// GitHub pages deployment config.
24-
// If you aren't using GitHub pages, you don't need these.
25-
organizationName: 'metacall', // Usually your GitHub org/user name.
26-
projectName: 'doc', // Usually your repo name.
21+
organizationName: 'mox678', // your GitHub user/org
22+
projectName: 'docs2', // repo name
2723
deploymentBranch: 'gh-pages',
2824

2925
onBrokenLinks: 'warn',
3026
onBrokenMarkdownLinks: 'warn',
3127

32-
// Even if you don't use internationalization, you can use this field to set
33-
// useful metadata like html lang. For example, if your site is Chinese, you
34-
// may want to replace "en" with "zh-Hans".
3528
i18n: {
3629
defaultLocale: 'en',
3730
locales: ['en'],
@@ -44,26 +37,20 @@ const config = {
4437
({
4538
docs: {
4639
sidebarPath: './sidebars.js',
47-
48-
49-
tagsBasePath: "tags",
50-
breadcrumbs: true,
51-
52-
40+
tagsBasePath: 'tags',
41+
breadcrumbs: true,
5342
},
5443
theme: {
5544
customCss: './src/css/custom.css',
5645
},
5746
}),
5847
],
5948
],
60-
61-
49+
6250
themeConfig:
6351
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
6452
({
65-
customCss: './src/css/custom.css', // Correct placement for customCss
66-
// Replace with your project's social card
53+
customCss: './src/css/custom.css',
6754
image: 'img/docusaurus-social-card.jpg',
6855
navbar: {
6956
title: 'Metacall Docs',
@@ -78,112 +65,77 @@ const config = {
7865
position: 'left',
7966
label: 'Documentation',
8067
},
68+
// Use "to" for internal Docusaurus routes
8169
{
82-
label: "Install",
83-
href: "/docs/category/installating-metacall-cli",
84-
position: "left",
70+
label: 'Install',
71+
to: '/docs/category/installating-metacall-cli',
72+
position: 'left',
8573
},
8674
{
87-
label: "Tutorials",
88-
href: "/docs/category/tutorials",
89-
position: "left",
75+
label: 'Tutorials',
76+
to: '/docs/category/tutorials',
77+
position: 'left',
9078
},
9179
{
92-
label: "Google Summer of Code 2025",
93-
href: "/docs/gsoc",
94-
position: "left",
80+
label: 'Google Summer of Code 2025',
81+
to: '/docs/gsoc',
82+
position: 'left',
9583
},
9684
{
9785
href: '/starred',
9886
label: '⭐ Stars',
9987
position: 'right',
10088
},
101-
10289
{
10390
href: 'https://github.com/metacall',
10491
label: 'GitHub',
10592
position: 'right',
10693
},
107-
10894
],
10995
},
110-
96+
11197
footer: {
112-
style: "dark",
98+
style: 'dark',
11399
links: [
114100
{
115-
title: "Intro",
101+
title: 'Intro',
116102
items: [
117-
{
118-
label: "Getting Started",
119-
to: "/docs/getting-started",
120-
},
121-
{
122-
label: "Install",
123-
to: "/docs/category/installating-metacall-cli",
124-
},
125-
103+
{ label: 'Getting Started', to: '/docs/getting-started' },
104+
{ label: 'Install', to: '/docs/category/installating-metacall-cli' },
126105
],
127106
},
128107
{
129-
title: "Use MetaCall",
108+
title: 'Use MetaCall',
130109
items: [
131-
{
132-
label: "Tutorials",
133-
to: "/docs/category/tutorials",
134-
},
135-
{
136-
label: "Deployment",
137-
to: "/docs/deployment",
138-
},
110+
{ label: 'Tutorials', to: '/docs/category/tutorials' },
111+
{ label: 'Deployment', to: '/docs/deployment' },
139112
],
140113
},
141114
{
142-
title: "Community",
115+
title: 'Community',
143116
items: [
144-
{
145-
label: "Discord",
146-
to: "https://discord.gg/upwP4mwJWa",
147-
},
148-
{
149-
label: "Telegram",
150-
to: "https://t.me/joinchat/BMSVbBatp0Vi4s5l4VgUgg",
151-
},
152-
{
153-
label: "Matrix",
154-
to: "https://matrix.to/#/#metacall:matrix.org",
155-
},
156-
117+
{ label: 'Discord', href: 'https://discord.gg/upwP4mwJWa' },
118+
{ label: 'Telegram', href: 'https://t.me/joinchat/BMSVbBatp0Vi4s5l4VgUgg' },
119+
{ label: 'Matrix', href: 'https://matrix.to/#/#metacall:matrix.org' },
157120
],
158121
},
159122
{
160-
title: "More",
123+
title: 'More',
161124
items: [
162-
{
163-
label: "GitHub",
164-
href: "https://github.com/metacall/",
165-
},
166-
{
167-
label: "Gsoc",
168-
href: "/docs/Gsoc",
169-
},
170-
171-
{
172-
label: "Changelog",
173-
href: "https://github.com/metacall/core/releases",
174-
},
175-
125+
{ label: 'GitHub', href: 'https://github.com/metacall/' },
126+
{ label: 'Gsoc', href: '/docs/Gsoc' },
127+
{ label: 'Changelog', href: 'https://github.com/metacall/core/releases' },
176128
],
177129
},
178130
],
179131
copyright: `Copyright © ${new Date().getFullYear()} MetaCall. All Rights Reserved.`,
180132
},
133+
181134
prism: {
182135
theme: prismThemes.vsDark,
183136
darkTheme: prismThemes.vsDark,
184-
185137
},
186138
}),
187139
};
188140

189-
export default config;
141+
export default config;

0 commit comments

Comments
 (0)