Recipes
Sync with Master
A config to keep every PR up-to-date with master. Whenever the target branch of a PR updates, the PR will update.
# .kodiak.toml
version = 1
[update]
always = true # default: false
require_automerge_label = false # default: true
Automated dependency updates with Dependabot (or Renovate)
NOTE: Kodiak supports Dependabot and Renovate for dependency updates. Any mention of Dependabot can be substituted with Renovate.
Kodiak can automerge all Dependabot PRs if you configure Dependabot to open pull requests with our merge.automerge_label
label.
If you want to only merge specific upgrade types, like "major", "minor", "patch", instead configure merge.automerge_dependencies
.
Configuring automerge by upgrade type
- Install Kodiak following the quick start guide.
- Add
"dependabot"
and your automerge upgrade types to the.kodiak.toml
NOTE: Remove the
[bot]
suffix from GitHub Bot usernames. Instead of"dependabot[bot]"
use"dependabot"
. Instead of"renovate[bot]"
use"renovate"
.
# .kodiak.toml
[merge]
automerge_label = "ship it!"
[merge.automerge_dependencies]
# auto merge all PRs opened by "dependabot" that are "minor" or "patch" version upgrades. "major" version upgrades will be ignored.
versions = ["minor", "patch"]
usernames = ["dependabot"]
# if using `update.always`, add dependabot to `update.ignore_usernames` to allow
# dependabot to update and close stale dependency upgrades.
[update]
ignored_usernames = ["dependabot"]
Configuring Dependabot with the automerge label
Install Kodiak following the quick start guide.
Configure dependabot to open PRs with your
merge.automerge_label
label. See the Dependabot labels documentation for more information.
# dependabot.yml
# Specify labels for pull requests
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
labels:
- "dependencies"
# Add default Kodiak `merge.automerge_label`
- "automerge"
- Success! Dependabot PRs will now include your automerge label, triggering Kodiak to automatically merge them. 🎉
Adding pull request approvals to Dependabot pull requests
When "Required approving reviews" is configured via GitHub Branch Protection, every pull request needs an approving review before it can be merged.
Kodiak can add an approval to pull requests via approve.auto_approve_usernames
, enabling Dependabot PRs to be merged without human intervention.
NOTE: Remove the
[bot]
suffix from GitHub Bot usernames. Instead of"dependabot[bot]"
use"dependabot"
. Instead of"renovate[bot]"
use"renovate"
.
# .kodiak.toml
version = 1
[approve]
# note: remove the "[bot]" suffix from GitHub Bot usernames.
# Instead of "dependabot[bot]" use "dependabot".
auto_approve_usernames = ["dependabot"]
# if using `update.always`, add dependabot to `update.ignore_usernames` to allow
# dependabot to update and close stale dependency upgrades.
[update]
ignored_usernames = ["dependabot"]
If you use Kodiak with update.always
enabled, add Dependabot to the update.ignored_usernames
list. If a PR by Dependabot is updated by another user, Dependabot will not update or close the PR when stale. This setting prevents Kodiak from breaking Dependabot PRs.
The Favourite
This is the config used by the Kodiak repository.
We squash all PR commits and use the PR title and body for the merge commit. Once merged, we delete the PR's branch.
# .kodiak.toml
version = 1
[merge.message]
title = "pull_request_title" # default: "github_default"
body = "pull_request_body" # default: "github_default"
Efficient Merges
By default, Kodiak will efficiently merge pull requests.
When "Require branches to be up to date before merging" is enabled via GitHub Branch Protection settings, a pull request's branch must be up-to-date with the target branch before merge. In this case Kodiak will update a pull request just before merge.
If we had multiple PRs waiting to be merged, each PR would only be updated (if required) just before to merge.
# .kodiak.toml
# Kodiak is efficient by default
version = 1
See "Efficient Merging" for more information about efficiency.
Speedy Merges
By default, pull requests are merged on a first-come-first-served policy for the merge queue. Enabling merge.prioritize_ready_to_merge
bypasses the queue for any PR that can be merged without updates.
Assuming "Require branches to be up to date before merging" is enabled via GitHub Branch Protection settings, when update.always
is enabled, a pull request's branch will be updated when the target branch updates. This option may improve merge speeds but wastes resources.
# .kodiak.toml
version = 1
[merge]
# if a PR is ready, merge it, don't place it in the merge queue.
prioritize_ready_to_merge = true # default: false
[update]
# immediately update a pull request's branch when outdated.
always = true # default: false
Better Merge Messages
GitHub's default merge commits are ugly. GitHub uses the title of the first commit for the merge title and combines all of the other commit titles and bodies for the merge body.
Using the pull request title and body give a cleaner, more useful merge commit.
This config uses the PR title and body, along with the PR number to create a nice merge commit. Additionally we strip HTML comments from the PR markdown body which can be useful if your GitHub repo has PR templates.
# .kodiak.toml
version = 1
[merge.message]
# use title of PR for merge commit.
title = "pull_request_title" # default: "github_default"
# use body of PR for merge commit.
body = "pull_request_body" # default: "github_default"
# add the PR number to the merge commit title, like GitHub.
include_pr_number = true # default: true
# use the default markdown content of the PR for the merge commit.
body_type = "markdown" # default: "markdown"
# remove html comments to auto remove PR templates.
strip_html_comments = true # default: false