This is a step-by-step guide to auto-update dependencies of GitLab projects using Renovate.
We will be using this project in the end part of this tutorial.
renovate-bot
in this tutorial)repo
scopeapi
scoperenovate-bot
GitLab projectGo to renovate-bot
’s CI/CD Settings
Scroll down to the Variables section, then expand it.
Then add a variable named GITHUB_COM_TOKEN
and give it the value of the PAT from GitHub you created in step 2.
Add another variable named RENOVATE_TOKEN
and give it the value of the PAT from GitHub you created in step 3.
You should have two environment variables added by now, like in this image below:
.gitlab-ci.yml
in your GitLab repositoryPaste this into that file:
update_repositories:
image: renovate/renovate:31.55
script:
- docker-entrypoint.sh
variables:
GITHUB_COM_TOKEN: $GITHUB_COM_TOKEN
RENOVATE_TOKEN: $RENOVATE_TOKEN
only:
- schedules
config.js
,module.exports = {
onboardingConfig: {
extends: ["config:base"],
},
platform: "gitlab",
gitAuthor: "RenovateBot <renovatebot@gmail.com>",
baseBranches: ["main", "master"],
labels: ["dependencies"],
repositories: [
"jeremiahflaga/renovate-bot",
"jeremiahflaga/sample-nodejs-app",
],
};
The repositories
in that setting contains the names of the projects we created in step 0 and step 1 of this tutorial, because those are the projects whose dependencies we want to be updated by Renovate.
Note that in your own project you have to change the repositories
part of that settings.
Please refer to the following tutorial for information about these settings: “Use Renovate to Manage Dependencies in Gitlab” by Joonas Venäläine
renovate.json
,{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base"]
}
Please refer to “Use Renovate to Manage Dependencies in Gitlab” by Joonas Venäläine for an explanation of these settings.
Go to CI/CD -> Schedules, then create a new schedule.
(Note: you can also manually trigger the schedule.)
When the CI/CD pipeline is triggered, a new merge request will be sent to the repositories
listed in our config.js
.
Here is the merge request created for jeremiahflaga/renovate-bot
:
Here is the merge request created for jeremiahflaga/sample-nodejs-app
:
Note: If you want the merge request to be directed to other branches, like development
or production
, you have to overwrite the renovate.json
file in those target repositories like this:
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base"],
"dependencyDashboard": true,
"baseBranches": ["development", "production"]
}
(Note: update the renovate.json
in the main
or master
branch.)
Please refer to “Use Renovate to Manage Dependencies in Gitlab” by Joonas Venäläine for an explanation of these settings.
In the next minutes/hours/days, depending on the schedule of the CI/CD pipeline, the Renovate bot will create new merge requests like this:
Main reference: “Use Renovate to Manage Dependencies in Gitlab” by Joonas Venäläinen (January 19, 2022)
Other references:
“Renovate Your GitLab Projects Automatically” by Mike Barkmin
“How to Keep Software Dependencies Up-to-Date with Renovate” by Emmanuel Sys
“Update dependencies with Renovate” by Pavel Kutáč
“Automatic Dependency Updates with Renovate and Gitlab” by Max Rosin
“How to Update Dependencies Safely and Automatically with GitHub Actions and Renovate” by Ramón Morcillo