↓ Skip to main content

Automate Compose Updates with Renovate, GitHub, and GitOps

··1072 words·6 mins·
Table of Contents

Managing production container environments manually is tedious and error-prone: images update quickly and security fixes are released constantly. By combining Renovate, GitHub Actions, and GitOps, this process can be fully automated:

  • Renovate regularly checks the deployed container images and creates pull requests for updates.
  • GitHub Actions handles the automation of Renovate runs.
  • Any GitOps tool can automatically deploy changes from the Git repository to the Docker environment.

Renovate runs under its own GitHub App bot account, so updates are opened by a dedicated bot (flohoss-bot[bot]) rather than your personal account.

This creates a clean GitOps workflow for Docker updates.

The renovate-config Repository
#

It’s a best practice to maintain a separate repository for Renovate configuration, e.g., renovate-config. This way, you can monitor multiple repositories from a single configuration.

Renovate runs via a GitHub Action inside this repository and monitors the specified repositories.
Inside your renovate-config repository, create a config.js file.

Create a GitHub App Bot
#

Instead of using a personal access token, I run Renovate under its own GitHub App bot account (flohoss-bot[bot]). This keeps bot commits and pull requests clearly separated from my personal account and lets me grant exactly the permissions Renovate needs.

To create the app:

  1. Go to Settings → Developer settings → GitHub Apps → New GitHub App.
  2. Give it a name, e.g. flohoss-bot, and a homepage URL (any URL works, e.g. your own site).
  3. Webhooks can stay disabled — Renovate runs on a schedule via GitHub Actions, so it does not need to receive events.
  4. Grant the repository permissions Renovate requires:
PermissionAccess
ChecksRead and write
Commit statusesRead and write
ContentsRead and write
IssuesRead and write
Pull requestsRead and write
MetadataRead
Note

This is the minimal set for updating Docker images and opening pull requests. The Renovate docs also list Workflows (updating GitHub Actions files), Dependabot alerts (vulnerability alerts), Members (organization membership), and Administration (repo admin settings) — but since my target repositories contain only compose.yml files and no workflows, I can leave them off.

  1. Install the app only on the repositories it should manage (in my case docker-compose and stacks).
  2. Generate and download the private key (.pem file) — you will store it as a GitHub secret.

Security Considerations
#

  • The workflow mints a short-lived installation token (expires after 1 hour) with actions/create-github-app-token and revokes it again when the job finishes. This is far safer than a long-lived personal access token.
  • The token is scoped to exactly the repositories listed in the workflow’s repositories input — least privilege.
  • The app’s private key must live exclusively in a GitHub secret and never in the repository.
  • Because the target repositories set assignees, GitHub itself notifies you whenever the bot opens a pull request and assigns it to you.
  • The bot identity keeps automated commits and pull requests separate from your personal account.

App Secrets and Variables
#

Store the app credentials in the renovate-config repository:

  • Secret RENOVATE_APP_PRIVATE_KEY — the content of the downloaded .pem file.
  • Variable RENOVATE_APP_ID — the app’s ID.

Renovate authenticates directly with the GitHub App installation token, so commits and pull requests are automatically attributed to the bot (flohoss-bot[bot]) — no custom gitAuthor or bot-name configuration is needed.

Renovate Configuration
#

You can find my example configuration in the renovate-config repository:

module.exports = {
    platform: 'github',
    token: process.env.RENOVATE_TOKEN,
    repositories: ['flohoss/docker-compose', 'flohoss/stacks'],
    onboarding: false,
    requireConfig: 'optional',
    dependencyDashboard: true,
    hostRules: [
        {
            matchHost: 'docker.io',
            username: process.env.RENOVATE_DOCKER_HUB_USERNAME,
            password: process.env.RENOVATE_DOCKER_HUB_PASSWORD,
        },
        {
            matchHost: 'ghcr.io',
            username: process.env.RENOVATE_GHCR_USERNAME,
            password: process.env.RENOVATE_GHCR_TOKEN,
        }
    ],
};
Note

Credentials (e.g., Docker Hub or GitHub Container Registry) must come exclusively from GitHub Secrets.

You can customize the configuration as needed.

GitHub Action Workflow
#

The corresponding GitHub workflow controls the Renovate execution. It first mints a short-lived installation token with actions/create-github-app-token and passes it to Renovate, so the resulting pull requests appear as opened by flohoss-bot[bot]:

name: renovate

on:
  workflow_dispatch:
  schedule:
    - cron: '42 1,13 * * *' # 03:42 & 15:42 CEST (summer), 02:42 & 14:42 CET (winter)

jobs:
  renovate:
    name: renovate
    runs-on: ubuntu-latest
    steps:
      - name: Get token
        id: get_token
        uses: actions/create-github-app-token@v3.3.0
        with:
          private-key: ${{ secrets.RENOVATE_APP_PRIVATE_KEY }}
          client-id: ${{ vars.RENOVATE_APP_CLIENT_ID }}
          owner: ${{ github.repository_owner }}
          repositories: 'docker-compose,stacks'

      - name: Checkout
        uses: actions/checkout@v7
      - name: Run Renovate
        uses: renovatebot/github-action@v46.3.11
        with:
          token: ${{ steps.get_token.outputs.token }}
          configurationFile: ${{ github.workspace }}/config.js
        env:
          RENOVATE_DOCKER_HUB_USERNAME: ${{ vars.DOCKER_HUB_USERNAME }}
          RENOVATE_DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
          RENOVATE_GHCR_USERNAME: ${{ vars.GHCR_USERNAME }}
          RENOVATE_GHCR_TOKEN: ${{ secrets.RENOVATE_TOKEN }}

Renovate Configuration in Compose Repositories
#

Through the renovate.json file, you can set rules to determine which images are updated or restricted to certain versions. The assignees option tells GitHub who to notify when the bot opens a pull request. Check out my stacks repository and its renovate.json file as an example:

{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "extends": ["config:recommended"],
  "assignees": ["flohoss"],
  "semanticCommits": "disabled",
  "prHourlyLimit": 0,
  "dependencyDashboard": true,
  "packageRules": [
    {
      "matchDatasources": ["docker"],
      "matchPackageNames": ["ghcr.io/immich-app/postgres"],
      "matchUpdateTypes": ["major", "minor", "patch"],
      "enabled": false
    },
    {
      "matchDatasources": ["docker"],
      "matchPackageNames": ["redis"],
      "allowedVersions": "8.x"
    },
    {
      "matchDatasources": ["docker"],
      "matchPackageNames": ["postgres"],
      "allowedVersions": "17.x"
    },
    {
      "matchDatasources": ["docker"],
      "matchPackageNames": ["mariadb"],
      "allowedVersions": "10.x"
    },
    {
      "matchManagers": ["custom.regex"],
      "matchFileNames": ["netbird/**"],
      "matchDepNames": ["maxlerebourg/crowdsec-bouncer-traefik-plugin"],
      "enabled": false
    },
    {
      "matchDatasources": ["docker"],
      "matchFileNames": ["netbird/**"],
      "matchDepNames": ["traefik", "crowdsecurity/crowdsec"],
      "enabled": false
    },
    {
      "matchDatasources": ["docker"],
      "matchPackageNames": ["netbirdio/dashboard", "netbirdio/netbird-server", "netbirdio/reverse-proxy"],
      "groupName": "NetBird"
    },
    {
      "matchDatasources": ["docker"],
      "matchPackageNames": ["ghcr.io/immich-app/immich-machine-learning", "ghcr.io/immich-app/immich-server"],
      "groupName": "Immich",
      "separateMinorPatch": false,
      "separateMultipleMajor": false
    },
    {
      "matchDatasources": ["docker"],
      "matchPackageNames": ["dock.mau.dev/mautrix/signal", "dock.mau.dev/mautrix/telegram", "dock.mau.dev/mautrix/whatsapp", "dock.mau.dev/mautrix/meta"],
      "groupName": "Mautrix",
      "separateMinorPatch": false,
      "separateMultipleMajor": false
    },
    {
      "matchDatasources": ["docker"],
      "pinDigests": true
    }
  ],
  "customManagers": [
    {
      "customType": "regex",
      "description": "Track the Traefik CrowdSec bouncer plugin, which is a Traefik command flag rather than an image",
      "managerFilePatterns": ["**/compose.{yml,yaml}"],
      "matchStrings": ["--experimental\\.plugins\\.bouncer\\.version=(?<currentValue>v[0-9.]+)"],
      "depNameTemplate": "maxlerebourg/crowdsec-bouncer-traefik-plugin",
      "datasourceTemplate": "github-releases",
      "versioningTemplate": "regex:^v(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)$"
    }
  ]
}

Examples:

  • Redis will only be updated within major version 7.
  • Postgres will only be updated within major version 17.
  • All images are digest-pinned for reproducible builds.

GitOps with Portainer, Dockhand, etc.
#

Finally, a GitOps tool continuously deploys the changes to your Docker environment. I use Dockhand for this purpose, but many other tools are available.

Note

Once you merge the Renovate PRs, the GitOps tool automatically pulls the changes and redeploys the stacks referencing the updated Git repository.

Result
#

  • Pull requests opened by your own bot (flohoss-bot[bot]) whenever new versions are available, with GitHub notifying you as assignee.
  • All changes are versioned and traceable via Git.
  • The GitOps tool ensures automated deployment in the Docker environment.

Resources
#