diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3b43b6a..2f6f5f2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -113,23 +113,17 @@ on: env: TZ: Asia/Shanghai -# =========================== -# 权限设置 (关键修改) -# =========================== +# 权限设置 permissions: contents: read - pages: write # GitHub Pages 部署需要 - id-token: write # GitHub Pages 部署需要 + pages: write + id-token: write -# 并发控制 concurrency: group: pages cancel-in-progress: false jobs: - # ================================================== - # 任务 1: 构建项目 + 部署到 1Panel + 上传构建产物 - # ================================================== build: runs-on: ubuntu-latest strategy: @@ -158,7 +152,7 @@ jobs: run: npm run build # -------------------------------------------------- - # 分支任务 A: 部署到 1Panel 服务器 (SCP) + # 分支任务 A: 部署到 1Panel (路径已修改) # -------------------------------------------------- - name: Deploy to 1Panel via SCP uses: appleboy/scp-action@master @@ -167,8 +161,15 @@ jobs: username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} + + # 源文件 (保持不变) source: "docs/.vitepress/dist/*" - target: "/www/wwwroot/handsome_blog" + + # 【关键修改】目标路径改为 1Panel 指定的路径 + # 注意:这里假设你在 1Panel 创建网站时,代号填的是 "blog" + target: "/opt/1panel/apps/openresty/openresty/www/sites/blog/index" + + # 去掉路径前缀 strip_components: 3 - name: Fix 1Panel Permissions @@ -179,7 +180,9 @@ jobs: password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} script: | - chown -R 1000:1000 /www/wwwroot/handsome_blog + # 【关键修改】修复新路径的权限 + # 1Panel 容器通常使用 1000:1000 作为 www 用户 + chown -R 1000:1000 /opt/1panel/apps/openresty/openresty/www/sites/blog/index # -------------------------------------------------- # 准备分支任务 B: 为 GitHub Pages 上传构建产物 @@ -187,22 +190,17 @@ jobs: - name: Upload artifact for GitHub Pages uses: actions/upload-pages-artifact@v3 with: - # 指定构建输出目录 (VitePress 默认为 docs/.vitepress/dist) path: docs/.vitepress/dist # ================================================== - # 任务 2: 部署到 GitHub Pages (依赖任务 1 完成) + # 任务 2: 部署到 GitHub Pages # ================================================== deploy-gh-pages: needs: build - - # 部署环境配置 environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - steps: - name: Deploy to GitHub Pages id: deployment