↓ Skip to main content

Self-hosted Renovate on Codeberg

··940 words·5 mins
Table of Contents
Renovate - This article is part of a series.
Part 1: This Article

Unlike GitHub, Codeberg has no hosted Renovate bot; it has to be set up and self-hosted. A central Renovate repository for the configuration and a scheduled pipeline in Woodpecker CI handle that very reliably.

This first part of the series covers the central repository; the following parts deal with onboarding a project, handling many open PRs, and signed commits.

One repository for everything
#

Renovate could run as a separate pipeline in every project, but a central repository gets by with a single pipeline, token and preset. The renovate-config repository contains the three files this part is about:

  • .woodpecker/renovate.yaml: the pipeline that runs Renovate against all repositories
  • default.json: the preset each project pulls into its own renovate.json
  • renovate.json: the config of renovate-config itself, which pulls in the preset as well

A change to the preset applies to all projects on the next run. The token needs write access to every repository and is stored as a repository secret only in the Woodpecker project of renovate-config. An organization secret would be available to every pipeline of every repository in the account. The Woodpecker project can be public or private. Its logs list every repository the token can access, private ones included.

Pipeline
#

The pipeline in renovate-config/.woodpecker/renovate.yaml runs daily at 4 am via the cron renovate and can be started manually. The pipeline doesn’t need to clone any repositories; Renovate takes care of that itself. The cron itself is created in the settings of the Woodpecker project.

when:
  - event: cron
    cron: renovate
  - event: manual

skip_clone: true

steps:
  - name: renovate
    image: renovate/renovate:44.240.0
    environment:
      RENOVATE_PLATFORM: forgejo
      RENOVATE_ENDPOINT: https://codeberg.org
      RENOVATE_AUTODISCOVER: "true"
      RENOVATE_ONBOARDING: "false"
      RENOVATE_REQUIRE_CONFIG: "required"
      LOG_LEVEL: ${LOG_LEVEL=info}
      RENOVATE_TOKEN:
        from_secret: renovate_token
      GITHUB_COM_TOKEN:
        from_secret: github_token

Forgejo is a platform of its own in Renovate, built on top of the Gitea implementation. Renovate knows the /api/v1 path from there, so the base URL is enough as the endpoint.

Autodiscover picks up every repository the token can access. With onboarding: false and requireConfig: required, Renovate opens no onboarding PRs and, of all the repositories it finds, only processes those with their own renovate.json; the rest show up in the log as disabled-no-config.

Both tokens are stored as the secrets renovate_token and github_token in the Woodpecker project. The Codeberg token is a PAT with the scopes listed in the Renovate docs: repository: rw, user: r, issue: rw, organization: r. The GitHub token covers lookups and release notes from github.com; a classic PAT without any scopes is enough.

LOG_LEVEL is set via string substitution in the pipeline. That’s the only way variables from the manual run dialog reach a step without commands, so a manual run with LOG_LEVEL=debug produces a debug log.

Renovate can also run locally against a single repository, without the pipeline:

read -rs RENOVATE_TOKEN && export RENOVATE_TOKEN
docker run --rm -e RENOVATE_TOKEN -e LOG_LEVEL=debug \
  -e RENOVATE_PLATFORM=forgejo -e RENOVATE_ENDPOINT=https://codeberg.org \
  renovate/renovate:44 <owner>/<repo>

Preset
#

The preset in renovate-config/default.json extends config:recommended:

{
  "extends": ["config:recommended", ":enablePreCommit", ":semanticCommits"],
  "branchPrefix": "chore/renovate-",
  "prHourlyLimit": 0,
  "timezone": "Europe/Berlin",
  "minimumReleaseAge": "3 days",
  "minimumReleaseAgeBehaviour": "timestamp-optional",
  "osvVulnerabilityAlerts": true,
  "vulnerabilityAlerts": {
    "labels": ["security"],
    "schedule": ["at any time"],
    "minimumReleaseAge": null
  },
  "lockFileMaintenance": {
    "enabled": true,
    "schedule": ["* * 1 * *"]
  },
  "nix": { "enabled": true },
  "packageRules": [
    {
      "matchPackageNames": ["renovate/renovate"],
      "schedule": ["* * * * 1"]
    },
    {
      "matchPackageNames": ["/shellcheck/", "/markdownlint-cli2/i", "/ripsecrets/"],
      "groupName": "linters"
    }
  ]
}

branchPrefix sets the prefix for Renovate’s branches. Renovate deletes branches with this prefix that have no open PR as orphaned, so manually created branches never start with chore/renovate-. prHourlyLimit: 0 lifts the limit of 2 new PRs per hour and repository. :enablePreCommit and nix turn on the managers for pre-commit hooks and Nix flakes, which are off by default.

Renovate keeps itself up to date: renovate-config is onboarded through its own renovate.json as well, so Renovate updates the image tag in its own pipeline. These updates only come on Mondays, as Renovate often publishes several releases a day. The linters group bundles updates for shellcheck, markdownlint-cli2 and ripsecrets, so CI images and pre-commit hooks of the same tool end up in the same PR.

Waiting period for new releases
#

Renovate only proposes a version 3 days after its release. While the waiting period runs, the branch carries the commit status renovate/stability-days as pending. Renovate writes this status itself through the Forgejo API, so it works with Woodpecker just as well as with Forgejo Actions.

Some releases have no timestamp, such as images from mcr.microsoft.com, or Docker Hub images when the Hub API aborts anonymous requests with a 403. minimumReleaseAgeBehaviour: timestamp-optional treats such releases as stable; the default timestamp-required would hold them back for good.

Security updates
#

osvVulnerabilityAlerts: true checks direct dependencies against the OSV database on any platform. vulnerabilityAlerts itself only reads alerts from GitHub, but it provides the settings for the OSV PRs: no waiting period, any time, and the security label.

Lock files
#

Renovate updates transitive dependencies in lock files such as yarn.lock or flake.lock through lockFileMaintenance, here once a month. The schedule * * 1 * * covers the whole 1st of the month, so the daily run at 4 am falls inside it regardless of the cron’s time zone. With timezone: Europe/Berlin, all schedules apply in German time instead of UTC.

Linting and badges
#

A second pipeline in renovate-config, .woodpecker/lint.yaml, checks PRs with renovate-config-validator --strict and markdownlint. Locally, the same checks run in a Nix dev shell via nix develop -c make lint.

The status badges in the README of renovate-config show the latest Renovate run and the lint result:

![renovate](https://ci.codeberg.org/api/badges/<owner>/renovate-config/status.svg?events=cron,manual&workflow=renovate)
![lint](https://ci.codeberg.org/api/badges/<owner>/renovate-config/status.svg?events=pull_request&workflow=lint)

Found this helpful?
Consider supporting via:

Renovate - This article is part of a series.
Part 1: This Article