Merging the default branch into a PR, from the API

Featured image for sharing metadata for article

When contributors raise PRs to Renovate, there are times where they'll merge main into their PR while they're waiting for a merge.

Because we use a Merge Queue, we don't necessarily need this - as maintainers we'll manually merge main into a PR if we think it needs it, but it's mostly a case of waiting for the Merge Queue to handle it.

Although we have a label that we add if we notice the author of a PR is merging main in - unnecessarily - we'll add a label which adds an automated nudge to say "you don't need to keep doing this", but are also making some tweaks in our contribution guidelines to make this clearer.

As one way to reduce the updating of PRs, we disabled - at a repo level - the Always suggest updating pull request branches setting, which removes the UI button.

However, that then means that a maintainer can't then merge the branch in from the UI - so we need another way to do so.

Fortunately the GitHub API has an API for this, which means that updating a PR is as simple as:

gh api /repos/renovatebot/renovate/pulls/44923/update-branch -X PUT

(We had tried to make this automagically work with GitHub Actions, but given the fact that github-actions[bot] authoring a commit on a branch means CI won't run, we still need a human (or a service account, which we don't want) in the loop)

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #github.

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.