Dependabotをauto mergeしていくGitHub Actions

多少の可用性を犠牲にして、セキュリティを優先したいリポジトリで使う
可用性 デプロイに失敗したり、動かなくなる可能性がある
ビジネス的な本番環境では許容しにくい
セキュリティ 手間をかけずにサプライチェーンをアップデートしていける
個人開発などでは使えそう

Dependabotはセキュリティアップデートに限定するか、cooldown期間を設定した方がいい
新しすぎるバージョンを自動で取り込んでいくことも、サプライチェーン攻撃に弱くなりそうなため

リポジトリ設定でauto mergeを有効化する

GitHub Actionsを入れる
.github/workflows/dependabot-auto-merge.yml
Copied!
# https://github.com/dependabot/fetch-metadata?tab=readme-ov-file#enabling-auto-merge
name: Dependabot auto-merge
on: pull_request
permissions:
pull-requests: write
contents: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'dependabot[bot]'
steps:
- run: gh pr merge --auto --merge "${{ github.event.pull_request.html_url }}"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

このGitHub Action自体には依存関係を持たせないよう、簡素化してある
メジャーアップデートだろうとマージされる前提で使う