diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml new file mode 100644 index 0000000..668197a --- /dev/null +++ b/.github/workflows/deploy-pages.yml @@ -0,0 +1,58 @@ +# ⚠️ GitHub Pages 仅能托管 H5 静态前端。 +# ClawApp 是前后端一体应用,用户仍需自行部署 server 端(WebSocket 代理)才能实际使用。 +# 此工作流仅构建并部署 h5/ 目录下的前端资源到 GitHub Pages。 + +name: Deploy to GitHub Pages + +on: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + + - name: Install dependencies + working-directory: ./h5 + run: npm ci + + - name: Build + working-directory: ./h5 + run: npx vite build --base /${{ github.event.repository.name }}/ + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./h5/dist + + deploy: + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/README.md b/README.md index 9e65a71..9fc181a 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,12 @@ pm2 start server/index.js --name clawapp pm2 save && pm2 startup ``` +### GitHub Pages 部署(仅前端) + +项目自带 GitHub Actions 工作流(`.github/workflows/deploy-pages.yml`),push 到 `main` 分支后会自动将 H5 前端部署到 GitHub Pages。 + +> ⚠️ **注意:** ClawApp 是前后端一体应用,GitHub Pages 只能托管 H5 静态前端。用户**仍需自行部署 server 端**(WebSocket 代理服务)才能实际使用聊天功能。Pages 上的前端页面需要连接到一个运行中的 ClawApp Server,参见上方的部署方式。 + ---