diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-ghpage.yml similarity index 66% rename from .github/workflows/deploy-docs.yml rename to .github/workflows/deploy-ghpage.yml index 537cb8e525..ce7d12b2ba 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-ghpage.yml @@ -4,8 +4,10 @@ name: Deploy Docs on: push: branches: - # make sure this is the branch you are using - main + pull_request: + paths: + - '.github/workflows/deploy-ghpage.yml' jobs: deploy-gh-pages: @@ -15,16 +17,13 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - # if your docs needs submodules, uncomment the following line # submodules: true - - name: Install pnpm - uses: pnpm/action-setup@v2 + uses: pnpm/action-setup@v4 with: - version: 7 - run_install: true - + version: 9.15.9 + run_install: false - name: Setup Node.js uses: actions/setup-node@v4 @@ -38,11 +37,19 @@ jobs: - name: Build Docs env: NODE_OPTIONS: --max_old_space_size=8192 + DEPLOY_PLATFORM: github run: |- pnpm run docs:build > docs/.vuepress/dist/.nojekyll + - name: Upload Build Artifacts + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + path: docs/.vuepress/dist + - name: Deploy + if: github.event_name == 'push' && github.ref == 'refs/heads/main' uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts index e311ecff22..fbfe8e6476 100644 --- a/docs/.vuepress/config.ts +++ b/docs/.vuepress/config.ts @@ -5,9 +5,17 @@ import theme from "./theme.js"; const __dirname = getDirname(import.meta.url); +const getBasePath = () => { + const platform = process.env.DEPLOY_PLATFORM; + if (platform === 'github') { + return '/docs/'; + } + return '/'; +}; + export default defineUserConfig({ theme, - base: "/", // For Github Pages + base: getBasePath(), head: [ [ "link", diff --git a/package.json b/package.json index c5a0649333..3804744bc4 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "ecosystem": "npx tsx scripts/ecosystem.ts", "dev-build": "vuepress build docs", "docs:build": "pnpm ecosystem && vuepress build docs", + "docs:build:github": "DEPLOY_PLATFORM=github pnpm ecosystem && vuepress build docs", "docs:clean-dev": "vuepress dev docs --clean-cache", "docs:dev": "vuepress dev docs", "dev": "pnpm docs:dev"