From 58a779518f040f47e29489f4df4b233e912ae683 Mon Sep 17 00:00:00 2001
From: Sebastiaan ten Pas <st981@cam.ac.uk>
Date: Thu, 20 Mar 2025 16:43:49 +0000
Subject: [PATCH] feat(renovatebot): add page about running post-upgrade tasks

---
 docs/howtos/renovatebot/post-upgrade-tasks.md | 49 +++++++++++++++++++
 mkdocs.yml                                    |  1 +
 pyproject.toml                                |  3 ++
 3 files changed, 53 insertions(+)
 create mode 100644 docs/howtos/renovatebot/post-upgrade-tasks.md
 create mode 100644 pyproject.toml

diff --git a/docs/howtos/renovatebot/post-upgrade-tasks.md b/docs/howtos/renovatebot/post-upgrade-tasks.md
new file mode 100644
index 00000000..f01b3f29
--- /dev/null
+++ b/docs/howtos/renovatebot/post-upgrade-tasks.md
@@ -0,0 +1,49 @@
+---
+title: Post-upgrade tasks
+---
+# Running post-upgrade tasks
+
+[Post-upgrade tasks](https://docs.renovatebot.com/configuration-options/#postupgradetasks) that are
+executed before a commit is made by Renovate.
+
+Post-upgrade tasks are commands that are executed by Renovate after a dependency has been updated
+but before the commit is created. The intention is to run any other command line tools that would
+modify existing files or generate new files when a dependency changes.
+
+Each command must match at least one of the patterns defined in allowedCommands (a global-only
+configuration option) in order to be executed.
+[Our configuration](https://gitlab.developers.cam.ac.uk/uis/devops/infra/gitlab-bots-deployment/-/blob/main/renovatebot-config.js?ref_type=heads#L97)
+is set up such that it can call scripts in the `./.renovate/` directory in the root that start with `post-upgrade*`.
+
+Note: make sure that the script is executable.
+
+Examples usages:
+
+{% raw %}
+
+```json
+  "postUpgradeTasks": {
+    "commands": [
+        "./.renovate/post-upgrade.py '{{{ toJSON upgrades }}}'"
+    ],
+    "executionMode": "branch",
+    "fileFilters": ["CHANGELOG.md"]
+  }
+```
+
+{% endraw %}
+
+Or:
+
+{% raw %}
+
+```json
+  "postUpgradeTasks": {
+    "commands": [
+        ".renovate/post-upgrade.sh \"{{{depName}}}\" \"{{{currentVersion}}}\" \"{{{newVersion}}}\""
+    ],
+    "fileFilters": ["CHANGELOG.md"]
+  }
+```
+
+{% endraw %}
diff --git a/mkdocs.yml b/mkdocs.yml
index 5000cb1f..407abed0 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -206,6 +206,7 @@ nav:
           - howtos/renovatebot/trigger-renovatebot-from-gitlab-ui.md
           - howtos/renovatebot/trigger-renovatebot-from-cli.md
           - howtos/renovatebot/trigger-renovatebot-from-ci.md
+        - howtos/renovatebot/post-upgrade-tasks.md
   - "Tutorials":
       - tutorials/index.md
       - tutorials/automating-gitlab-releases.md
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 00000000..e35b9987
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,3 @@
+[tool.poe.tasks.fix]
+help = "Run pre-commit checks to fix formatting errors"
+cmd = "pre-commit run --all-files"
-- 
GitLab