Skip to content

chore(ci): 收斂依賴機器人為單一 Dependabot 並補齊分組與自動合併 - #1023

Merged
s123104 merged 1 commit into
mainfrom
chore/dependabot-governance
Aug 23, 2026
Merged

chore(ci): 收斂依賴機器人為單一 Dependabot 並補齊分組與自動合併#1023
s123104 merged 1 commit into
mainfrom
chore/dependabot-governance

Conversation

@s123104

@s123104 s123104 commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

問題

盤點 open PR 時發現 6 個 Dependabot PR 長期堆積,其中 #1014#979 checks 全綠卻掛置數週#980#995 是同一個 react-router-dom v7 升級的重複 PR。追下去發現根因不是 Dependabot 設定太寬,而是自動化責任被交給了一個從未生效的機器人。

根因:renovate.json 是死設定

證據 結果
gh pr list --author app/renovate --state all 0 筆
Renovate Dependency Dashboard issue 不存在
renovate.json 建立時間 2025-12-26(docs/dev/034

Renovate App 從未安裝,這份含 automerge: true 的設定 8 個月完全沒有生效

更糟的是 .github/dependabot.yml 依照同一份文件被刻意降規格:

# 2025-12-26: 改為每週,避免與 Renovate 衝突(Renovate 週一執行)
# Dependabot 作為備援,僅處理 Renovate 遺漏的更新
open-pull-requests-limit: 3

於是唯一實際在跑的機器人失去 grouping 與自動合併能力 —— 034 文件當初想解決的「PR 堆積」問題原樣復發。

修改

1. 刪除 renovate.json,確立單一依賴機器人 SSOT。

2. .github/dependabot.yml

3. 新增 .github/workflows/dependabot-automerge.yml

  • minor/patchgh pr merge --auto --squash
  • major → 只加 major-update 標籤(gh label create --force 確保冪等,不依賴 repo 端手動前置設定)
  • 分組 PR 的 update-type 取群組內最高 semver,major 混入時整包落到人工審查,不會被誤自動合併

安全性

Dependabot 觸發的 pull_request 事件其 GITHUB_TOKEN 為唯讀,故必須用 pull_request_target 取得寫入權限。本 workflow 刻意不 checkout PR 分支、不執行 PR 內任何程式碼,僅呼叫 GitHub API,避免 pull_request_target 的權限提升風險。

合併仍由 branch protection 與 required checks 把關 —— auto-merge 只是排隊機制,checks 未過不會合併,不存在繞過審查控制的路徑。

4. 文件同步

  • docs/dev/034 標註 ⛔ 作廢並記錄失效原因(保留歷史,不刪除)
  • CLAUDE.md 新增「依賴機器人 SSOT」段落,禁止再引入第二套機器人設定
  • DEPENDENCY_UPGRADE_PLAN.md 移除已不適用的 Renovate 選項
  • README.md workflow 數量三處不一致(9 / 9 / 10)一併校正為實際的 13

驗證

項目 結果
兩份 YAML 解析 通過(3 個 update entry、grouping 與 limit 如預期)
002 記分守門 通過
pre-commit 六步 全綠(含全 workspace typecheck 與 prettier)

尚未處理

🤖 Generated with Claude Code

- 刪除 renovate.json:Renovate App 從未安裝,該設定自 2025-12-26 起 8 個月零生效
- dependabot.yml 為 npm 與 github-actions 加 minor/patch grouping,收斂每週 PR 數
- 補 /security-headers entry:該目錄自帶 npm lockfile 不在 pnpm workspace 內
- major 刻意不分組,避免相容性待評估的升級卡住同批安全更新
- 新增 dependabot-automerge workflow:minor/patch 掛 auto-merge、major 標 major-update
- 該 workflow 用 pull_request_target 取寫入權限,不 checkout PR 分支也不執行 PR 程式碼
- 合併仍由 branch protection 與 required checks 把關,auto-merge 僅為排隊機制
- 034 文件標註作廢並記錄失效原因,CLAUDE.md 立單一依賴機器人 SSOT 規則
- README workflow 數量三處不一致(9/9/10)一併校正為實際的 13

測試:python yaml 解析兩份設定通過;002 記分守門通過;pre-commit 六步全綠

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

The following issues were found:
  • ✅ 0 vulnerable package(s)
  • ✅ 0 package(s) with incompatible licenses
  • ✅ 0 package(s) with invalid SPDX license definitions
  • ⚠️ 1 package(s) with unknown licenses.
See the Details below.

License Issues

.github/workflows/dependabot-automerge.yml

PackageVersionLicenseIssue Type
dependabot/fetch-metadata2.*.*NullUnknown License
Denied Licenses: GPL-3.0, AGPL-3.0

OpenSSF Scorecard

PackageVersionScoreDetails
actions/dependabot/fetch-metadata 2.*.* 🟢 8.2
Details
CheckScoreReason
Binary-Artifacts🟢 10no binaries found in the repo
Packaging⚠️ -1packaging workflow not detected
Maintained🟢 1029 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Code-Review🟢 10all changesets reviewed
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Token-Permissions🟢 9detected GitHub workflow tokens with excessive permissions
Pinned-Dependencies🟢 3dependency not pinned by hash detected -- score normalized to 3
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Security-Policy🟢 10security policy file detected
Branch-Protection🟢 8branch protection is not maximal on development and all release branches
SAST🟢 10SAST tool is run on all commits

Scanned Files

  • .github/workflows/dependabot-automerge.yml

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7a9ed6314

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread CLAUDE.md
Comment on lines +208 to +210
- 自動化規則一律寫進 `.github/dependabot.yml`,**禁止**再引入第二套機器人設定造成重複 PR。
- minor/patch 由 `.github/workflows/dependabot-automerge.yml` 掛 GitHub auto-merge;major 只加 `major-update` 標籤,需人工評估相容性。
- 該 workflow 以 `pull_request_target` 取得寫入權限,**不得**在其中 checkout PR 分支或執行 PR 內程式碼。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 將依賴機器人新規則同步到 AGENTS.md

此處建立了「只准 Dependabot、禁止第二套機器人」的新 repo-wide CI 流程規則,但同一提交未更新根 AGENTS.md,使 Agent SOP 與 CLAUDE.md 的 SSOT 立即分歧;請將這套依賴機器人政策與安全限制同步寫入 AGENTS.md

AGENTS.md reference: AGENTS.md:L122-L122

Useful? React with 👍 / 👎.

Comment thread README.md
| **樣式** | Tailwind CSS 3.4 |
| **測試** | Vitest 4.1 + Playwright 1.57 |
| **套件管理** | pnpm 9.10.0 (Monorepo) |
| **CI/CD** | GitHub Actions (13 workflows) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 將 workflow 數量改為實際的 12

此提交完成後,git ls-tree.github/workflows 下只列出 12 個 YAML workflow(已包含新增的 Dependabot workflow),因此這裡以及同次修改的另外兩個「13」都會向使用者與稽核者提供錯誤的 CI 清單數量;請統一更正為 12,或避免硬編碼此統計值。

AGENTS.md reference: AGENTS.md:L163-L163

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant