Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to deploy multi vitepress blogs on github? #4498

Open
4 tasks done
gitforprivate opened this issue Jan 19, 2025 · 0 comments
Open
4 tasks done

How to deploy multi vitepress blogs on github? #4498

gitforprivate opened this issue Jan 19, 2025 · 0 comments
Labels
bug: pending triage Maybe a bug, waiting for confirmation

Comments

@gitforprivate
Copy link

Describe the bug

I want to deploy two different blogs on github,

  • these blogs has its own topic,
  • maintain their code in only one git repo

I tried monorepo,but it cannot work

Reproduction

工作流配置文件:

# 构建 VitePress 站点并将其部署到 GitHub Pages
#
name: Deploy VitePress sites to Pages

on:
  push:
    branches: [main]
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
concurrency:
  group: pages
  cancel-in-progress: false

jobs:
  # 构建languages博客
  build-blog-languages:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0 # 如果未启用 lastUpdated,则不需要
      - name: Install pnpm
        run: npm install -g pnpm@latest-10 # 安装 pnpm
      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: pnpm
      - name: Install dependencies in root
        run: pnpm install # 在根目录安装依赖
      - name: Build Blog languages with VitePress
        run: pnpm --filter languages run docs:build
      - name: Upload Blog A artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: languages/.vitepress/dist

  # 构建 frontend 博客
  build-blog-frontend:
    runs-on: ubuntu-latest
    needs: build-blog-languages
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: pnpm
      - name: Build Blog B with VitePress
        run: pnpm --filter frontend run docs:build
      - name: Upload Blog B artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: frontend/.vitepress/dist

  # 构建 Backend 博客
  build-blog-backend:
    runs-on: ubuntu-latest
    needs: build-blog-languages
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: pnpm
      - name: Build Blog backend with VitePress
        run: pnpm --filter backend run docs:build
      - name: Upload Blog B artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: backend/.vitepress/dist

  # 部署 A 博客到 GitHub Pages
  deploy-blog-languages:
    environment:
      name: github-pages
      url: ${{ steps.deploy-blog-languages.outputs.page_url }}
    needs: build-blog-languages
    runs-on: ubuntu-latest
    steps:
      - name: Deploy Blog languages to GitHub Pages
        id: deploy-blog-languages
        uses: actions/deploy-pages@v4
        with:
          path: languages/.vitepress/dist
          artifact_name: languages
          token: ${{ secrets.GITHUB_TOKEN }}

  # 部署 frontend 博客到 GitHub Pages
  deploy-blog-frontend:
    environment:
      name: github-pages
      url: ${{ steps.deploy-blog-frontend.outputs.page_url }}
    needs: build-blog-frontend
    runs-on: ubuntu-latest
    steps:
      - name: Deploy Blog frontend to GitHub Pages
        id: deploy-blog-frontend
        uses: actions/deploy-pages@v4
        with:
          path: frontend/.vitepress/dist
          artifact_name: frontend
          token: ${{ secrets.GITHUB_TOKEN }}

  # 部署 backend 博客到 GitHub Pages
  deploy-blog-backend:
    environment:
      name: github-pages
      url: ${{ steps.deploy-blog-backend.outputs.page_url }}
    needs: build-blog-backend
    runs-on: ubuntu-latest
    steps:
      - name: Deploy Blog backend to GitHub Pages
        id: deploy-blog-backend
        uses: actions/deploy-pages@v4
        with:
          path: backend/.vitepress/dist
          artifact_name: backend
          token: ${{ secrets.GITHUB_TOKEN }}

Expected behavior

when I type xxx.github.io/blogs/A ,it can show A blog,when I type xxx.github.io/blogs/B,it can show B blog

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-1240P
    Memory: 5.38 GB / 15.68 GB
  Binaries:
    Node: 20.12.2 - D:\Software\nvm\nodejs\node.EXE
    Yarn: 1.22.22 - D:\Software\nvm\nodejs\yarn.CMD
    npm: 10.5.0 - D:\Software\nvm\nodejs\npm.CMD
    pnpm: 10.0.0 - D:\Software\nvm\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (131.0.2903.112)
    Internet Explorer: 11.0.26100.1882       
  npmPackages:
    vitepress: ^1.5.0 => 1.5.0

Additional context

No response

Validations

@gitforprivate gitforprivate added the bug: pending triage Maybe a bug, waiting for confirmation label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: pending triage Maybe a bug, waiting for confirmation
Projects
None yet
Development

No branches or pull requests

1 participant