Automatic Dependency Update
Updating package dependencies automatically as a part of continuous integration (CI)
Dependabot¶
Dependabot creates a pull request once there is an update for the dependencies. The pull requests are usually tested by continuous integration (CI).
However, dependabot does not support automerging on its own due to security concerns. The good news is that we could use Kodiak to do the job. See it's quickstart if you are interested.
For example, the dependabot file .github/dependabot.yml
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
labels:
- "automerge"
Kodiak bot file: .github/.kodiak.toml
version = 1
[merge]
method = "squash"
And you need additional steps in the Github settings to make Kodiak Bot work
- Add the
automerge
tag in the GitHub issue tab. - In
Options
->Branches
, protect the to-be-merged branch (usually themain
branch) - Also tick "Require status checks to pass before merging" and "Require branches to be up to date before merging"
- And select which github action job(s) should be passed in order to automerge by using the search bar below.
Renovate¶
Renovate bot can manage both dependency update checking and automated pull request merging.
Renovate supports a variety of platforms
- GitHub (.com and Enterprise)
- GitLab (.com and CE/EE)
- Bitbucket Cloud / Servee
- Azure DevOps
- Gitea
And a variety of programming languages
- Git submodules
- GitHub actions
- Node JS packages
- Dockerfile
- Javascript (and node JS)
- Java
- And more
Setup for GitHub¶
Enable the Renovate GitHub APP for GitHub repositories. Renovate bot will open an pull request for reachable repos to begin an interactive setup.
Setup for GitLab¶
According to the renovate GitLab runner documentation,
- Create a repository for the Renovate runner.
- Add a GitLab personal access token (PAT) with
read_user
,api
andwrite_repository
scopes as theRENOVATE_TOKEN
CI/CD variable, - Add a GitHub PAT as
GITHUB_COM_TOKEN
. This token allows renovate bot to read information of updated dependencies unhindered. - Create
.gitlab-ci.yml
to run the pipelines
.gitlab-ci.ymlinclude: - project: 'renovate-bot/renovate-runner' file: '/templates/renovate-dind.gitlab-ci.yml'
- Select what repositories renovate bot could touch by setting up the CI/CD variable
RENOVATE_EXTRA_FLAGS
:--autodiscover=true --autodiscover-filter=group1/*
or configure them in theconfig.js
file.
config.jsmodule.exports = { repositories: [ "group1/repo1", "group2/repo2", ], };
As a plus, it's easier to set up more renovate runner options in theconfig.js
file. - Setup a schedule for the pipeline.
Renovate settings file¶
The settings file renovate.json
example
{
"extends": [
"config:recommended",
],
"git-submodules": {
"enabled": true
}
}