From ea164dd93b793c258caea82556049f8ce8298d70 Mon Sep 17 00:00:00 2001 From: liuxy <938651469@qq.com> Date: Sun, 15 Jun 2025 21:37:39 +0800 Subject: [PATCH 1/3] Fix For Github Pages fix https://openlistteam.github.io/docs/ --- docs/.vuepress/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts index e311ecff22..0f36f7efce 100644 --- a/docs/.vuepress/config.ts +++ b/docs/.vuepress/config.ts @@ -7,7 +7,7 @@ const __dirname = getDirname(import.meta.url); export default defineUserConfig({ theme, - base: "/", // For Github Pages + base: process.env.NODE_ENV === 'development' ? "/" : "/docs/", // For Github Pages head: [ [ "link", From b6a09e2393309e50ca9046f69e821bbfbf79ab46 Mon Sep 17 00:00:00 2001 From: Hantong Chen Date: Mon, 16 Jun 2025 00:38:54 +0800 Subject: [PATCH 2/3] fix: github pages assets --- .../{deploy-docs.yml => deploy-ghpage.yml} | 15 ++++++++------- docs/.vuepress/config.ts | 10 +++++++++- package.json | 1 + 3 files changed, 18 insertions(+), 8 deletions(-) rename .github/workflows/{deploy-docs.yml => deploy-ghpage.yml} (76%) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-ghpage.yml similarity index 76% rename from .github/workflows/deploy-docs.yml rename to .github/workflows/deploy-ghpage.yml index 537cb8e525..5b115ef617 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,13 @@ 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: 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 0f36f7efce..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: process.env.NODE_ENV === 'development' ? "/" : "/docs/", // 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" From 5c8bee75104d9580c57e9e9902526117d38f6000 Mon Sep 17 00:00:00 2001 From: Hantong Chen Date: Mon, 16 Jun 2025 00:55:20 +0800 Subject: [PATCH 3/3] feat: upload assets --- .github/workflows/deploy-ghpage.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/deploy-ghpage.yml b/.github/workflows/deploy-ghpage.yml index 5b115ef617..ce7d12b2ba 100644 --- a/.github/workflows/deploy-ghpage.yml +++ b/.github/workflows/deploy-ghpage.yml @@ -42,6 +42,12 @@ jobs: 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