Merge every green Dependabot PR in one command (and the trap that merges untested code)
Stop merging 20 green PRs by hand. You only need 1 command. Monday morning, a stack of dependency pull requests, most of them green. Opening each one to click merge is twenty minutes of nothing. We've all done it. The command gh pr list --author "app/dependabot" --state open \ --json number,statusCheckRollup \ --jq '.[] | select((.statusCheckRollup | length) > 0 and all(.statusCheckRollup[];…
Merge every green Dependabot PR with a single command, warns against the risk of merging untested code. Monday morning, a daunting stack of dependency pull requests awaits. Opening each one to click merge is a tedious twenty minutes many have experienced. The command simplifies the process: `gh pr list --author "app/dependabot" --state open --json number,statusCheckRollup --jq '.[] | select((.statusCheckRollup | length) > 0 and all(.statusCheckRollup[]; (.conclusion // .state) == "SUCCESS")) | .number' | xargs -n1 gh pr merge --squash`.
This merges only open PRs authored by Dependabot, ensuring every check run and commit status is SUCCESS before merging. However, a crucial line – `length > 0` – prevents a PR with no checks at all from passing, as "all of nothing" is considered true. This command traps the potential merging of a PR whose CI never ran or a path filter that skipped it.
To avoid this trap, always re-check before merging, as checks can fail between listing and merging, or new commits can land. Only version bumps should be batch-merged, not code changes. A migration requires human review, even if green. Dependabot PRs with NEUTRAL or SKIPPED checks remain unmerged, allowing manual decision-making.
Versyka offers a button on the Overview page titled "Merge all that passed CI", checking each PR again on GitHub right before merging, up to 20 per click. Reflect on how many green dependency PRs are currently open in your main repository.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to