Migrating Renovate bots, while keeping existing PRs updated

Featured image for sharing metadata for article

In the process of migrating from the Mend-hosted SAAS platform to a Self-Hosted deployment of Mend Renovate Community Edition, we've noticed that PRs raised by the SAAS platform, were not being updated by the Self-Hosted app.

This is down to the way that Renovate tries to not overwrite any changes that (usually a human) has pushed to one of its PRs, and that it naturally can't know that you're in the process of a migration between bots.

Our Dependency Dashboards were full of:

Edited/Blocked These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

This is down to our new Renovate bot internal-renovate[bot] not wanting to step on the toes of the existing bot, renovate[bot].

We didn't want to have to close (+ rename) all the PRs + delete branches to force Renovate to re-run, so started digging through documentation to find an alternative.

Fortunately, we can use the gitIgnoredAuthors configuration to exclude the SAAS GitHub App, by adding the following to our config.js:

module.exports = {
  gitIgnoredAuthors: [
    // the App ID + GitHub email address, via https://www.jvt.me/posts/2023/04/20/github-app-email-address/
    // alternatively, via a commit on an existing repository
    "29139614+renovate[bot]@users.noreply.github.com"
  ],
}

Once this was in place, Renovate was seeing the branches and was happy starting to modify them. However, we then hit:

{
  "level": 20,
  "branch": "renovate/github.com-urfave-cli-v2-2.x",
  "err": {
    "name": "HTTPError",
    "code": "ERR_NON_2XX_3XX_RESPONSE",
    "message": "Response code 422 (Unprocessable Entity)",
    "stack": "HTTPError: Response code 422 (Unprocessable Entity)\n ..."
  },
  "response": {
    "statusCode": 422,
    "statusMessage": "Unprocessable Entity",
    "body": {
    "message": "Validation Failed",
    "errors": [
      {
      "resource": "PullRequest",
      "code": "custom",
      "message": "A pull request already exists for ...:renovate/github.com-urfave-cli-v2-2.x"
      }
    ],
    "documentation_url": "https://docs.github.com/rest/pulls/pulls#create-a-pull-request",
    "status": "422"
    },
    "headers": {
    ...
    },
    "httpVersion": "1.1",
    "retryCount": 0
  }

As expected, there's already a PR from that branch, it just happened to be created by the SAAS bot.

To resolve this, I managed to find this GitHub Discussion which pointed towards ignorePrAuthor, which is used to support the migration between repos, by not performing the pre-optimised search to only find PRs raised by the authenticated bot.

Note that this is likely to cause performance degradation, especially on large repos, as Renovate will look through all PRs in the repo for ones that are Renovate-related.

Therefore, the final config.js you want is:

module.exports = {
  gitIgnoredAuthors: [
    // the App ID + GitHub email address, via https://www.jvt.me/posts/2023/04/20/github-app-email-address/
    // alternatively, via a commit on an existing repository
    "29139614+renovate[bot]@users.noreply.github.com"
  ],

  ignorePrAuthor: true,
}

And that should mean Renovate ✨ just works ✨

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 #renovate.

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.