From 1fc1b597ca3c23315a9e5b7505e64cd62b0481cd Mon Sep 17 00:00:00 2001 From: lwmacct Date: Thu, 27 Nov 2025 02:45:20 +0800 Subject: [PATCH 1/3] ci: Only trigger docs deployment when docs/ changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add paths filter to only run workflow when docs/** files change - Add PR build support (build without deploy for validation) - Add fetch-depth: 0 for complete git history - Use working-directory instead of cd commands - Skip deploy step for pull requests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/workflows/deploy-docs.yml | 51 +++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 9dbf50a..08cb86b 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -1,58 +1,77 @@ -name: Deploy to GitHub Pages +# 部署文档站点到 GitHub Pages +name: Deploy Docs to Pages +# 触发条件 on: + # 推送到 main 分支且 docs 目录有变更时触发 push: - branches: - - main + branches: [main] + paths: + - "docs/**" + - ".github/workflows/deploy-docs.yml" + + # PR 到 main 分支且 docs 目录有变更时触发(仅构建,不部署) pull_request: - branches: - - main + branches: [main] + paths: + - "docs/**" + - ".github/workflows/deploy-docs.yml" + + # 允许手动触发 workflow_dispatch: +# 设置 GitHub Pages 部署所需的权限 permissions: contents: read pages: write id-token: write +# 只允许一个并发部署 concurrency: - group: "pages" + group: pages cancel-in-progress: false jobs: + # 构建任务 build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '20' - cache: 'npm' - cache-dependency-path: 'docs/package-lock.json' + node-version: "20" + cache: "npm" + cache-dependency-path: "docs/package-lock.json" + + - name: Setup Pages + uses: actions/configure-pages@v5 - name: Install dependencies - run: | - cd docs - npm ci + run: npm ci + working-directory: docs - name: Build - run: | - cd docs - npm run generate + run: npm run generate + working-directory: docs - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: path: docs/.output/public + # 部署任务 deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest needs: build + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest steps: - name: Deploy to GitHub Pages id: deployment From 7b288eadeaa377735fc13f5124a8be84940ac7f6 Mon Sep 17 00:00:00 2001 From: lwmacct Date: Thu, 27 Nov 2025 02:54:31 +0800 Subject: [PATCH 2/3] ci: Add paths-ignore filter and timeout to Go CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Skip Go CI when only docs/ or markdown files change - Add timeout-minutes: 10 to build job to prevent hanging 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/workflows/go-ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/go-ci.yml b/.github/workflows/go-ci.yml index 88e64b9..ab5a7c4 100644 --- a/.github/workflows/go-ci.yml +++ b/.github/workflows/go-ci.yml @@ -5,10 +5,18 @@ on: branches: - main - develop + paths-ignore: + - "docs/**" + - "**.md" + - ".github/workflows/deploy-docs.yml" pull_request: branches: - main - develop + paths-ignore: + - "docs/**" + - "**.md" + - ".github/workflows/deploy-docs.yml" workflow_dispatch: permissions: @@ -44,6 +52,7 @@ jobs: build: name: Build runs-on: ubuntu-latest + timeout-minutes: 10 strategy: matrix: go-version: ['1.22', '1.23'] From 55ea647fc3896bc5bc747cb44c90a0ab45f62754 Mon Sep 17 00:00:00 2001 From: lwmacct Date: Thu, 27 Nov 2025 03:05:59 +0800 Subject: [PATCH 3/3] ci: Remove workflow file from paths trigger MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only trigger docs deployment when actual docs content changes, not when the workflow file itself is modified. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/workflows/deploy-docs.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 08cb86b..56ef72e 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -8,14 +8,12 @@ on: branches: [main] paths: - "docs/**" - - ".github/workflows/deploy-docs.yml" # PR 到 main 分支且 docs 目录有变更时触发(仅构建,不部署) pull_request: branches: [main] paths: - "docs/**" - - ".github/workflows/deploy-docs.yml" # 允许手动触发 workflow_dispatch: