できない.dev

GitHub Dependabot が PR を作成しない / 動かない

Dependabot が PR を作らないのは、`.github/dependabot.yml` の構文ミス、Security 設定で機能が無効、PR 上限到達、`package-ecosystem` 名の誤りの 4 系統。
Insights → Dependency graph → Dependabot のログでまず実行結果を確認する。

#dependabot#security#dependencies#automation#yaml

公開:

要約

Dependabot が PR を作らないときは、YAML 構文 → 機能の有効化 → PR 上限 → ecosystem 名 の順で切り分ける。
Insights → Dependency graph → Dependabot タブにエラー理由が出るので、勘で直す前にまずログを読む。

よくある原因

  1. YAML が壊れている: タブ混在 / インデントずれ / 未クォートのコロンで解析失敗。
    サイレントに無効化される
  2. 機能が無効: リポジトリ設定で Dependabot version updates 自体が OFF
  3. PR 上限: open-pull-requests-limit のデフォルト 5 に達すると、新規アップデートがあっても作成されない
  4. ecosystem 名違い: npmnodepippython などと書いて対象外になっている
  5. private registry: 認証 token を registries: に書いていないと private パッケージは更新対象外

解決策

1. ログを確認する

GitHub の Insights → Dependency graph → Dependabot タブに各 ecosystem ごとの最終実行結果が出る。
エラーがあればここに表示される。

2. 最小構成で書き直す

# .github/dependabot.yml
version: 2
updates:
  - package-ecosystem: "npm"
    directory: "/"
    schedule:
      interval: "weekly"
    open-pull-requests-limit: 10

package-ecosystem の正しい値は公式の Configuration optionsに列挙されている。

3. 機能を有効化する

Settings → Code security → Dependabot version updates を Enable に切り替える。
項目自体が出ない場合は、オーガニゼーション側のポリシーで無効化されている可能性がある。
version updates の概観は公式の About Dependabot version updatesを参照。

4. 上限を引き上げて既存 PR を整理する

open-pull-requests-limit: 10

既存の Dependabot PR を @dependabot rebase で更新するか、マージ / クローズして空きを作る。

5. private registry の認証を追加

registries:
  npm-github:
    type: npm-registry
    url: https://npm.pkg.github.com
    token: ${{secrets.GH_PACKAGES_TOKEN}}
 
updates:
  - package-ecosystem: "npm"
    directory: "/"
    registries:
      - npm-github
    schedule:
      interval: "weekly"

token は repo / org の Dependabot secrets として登録する(Actions Secrets とは別枠)。

この記事は役立ちましたか?