Skip to content

Instantly share code, notes, and snippets.

@jnewland
Last active November 3, 2020 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnewland/5a303d08355f6640efe2e592b79e16f6 to your computer and use it in GitHub Desktop.
Save jnewland/5a303d08355f6640efe2e592b79e16f6 to your computer and use it in GitHub Desktop.
Using renovate to automate updating the version of basically anything in an infra as code GitHub repo

Usage

Setup https://github.com/renovatebot/github-action and add renovate.json (below) to your repository. The versions of Terraform modules and providers, FROM statements in Dockerfiles, and image fields in Kubernetes configuration matching deployments/*.yaml will be automatically detected and update PRs will be created automatically.

To supplement this configuration, the regexmanagers in the included renovate.json enable automatic updates of most things that a) release versions in a format compatible with a supported datasource (like GitHub tags or releases) and b) configure their version in a YAML file or shell script.

Comment-annotated YAML Version Keys

jobs:
  kubectl-diff:
    name: kubectl-diff
    runs-on: ubuntu-latest
    env:
      # renovate: datasource=github-tags depName=kubernetes/kubernetes
      kubectl_version: v1.16.15

image

Comment-annotated VERSION variables in shell scripts

#!/bin/bash

# renovate: datasource=github-tags depName=kubernetes/kubernetes
KUBERNETES_VERSION=v1.16.4
wget https://dl.k8s.io/${KUBERNETES_VERSION}/kubernetes-node-linux-amd64.tar.gz

image

Versioned GitHub Release Asset URLs

curl -sL https://github.com/containernetworking/plugins/releases/download/v0.7.4/cni-plugins-amd64-v0.7.4.tgz -o cni-plugin.tgz

Versioned GitHub Repository Content URLs

apiVersion: urcomputeringpal.com/v1
kind: kurl
metadata:
  name: dashboard
argsOneLiner: https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.4/aio/deploy/recommended.yaml
{
"extends": ["config:base"],
"rebaseWhen": "never",
"kubernetes": {
"fileMatch": ["deployments/.+\\.yaml$"]
},
"packageRules": [
{
"packageNames": "renovatebot/github-action",
"extends": ["schedule:weekly"]
}
],
"regexManagers": [
{
"fileMatch": [".+"],
"datasourceTemplate": "github-tags",
"matchStrings": [
"https://raw\\.githubusercontent\\.com/(?<depName>[^/]+/[^/]+)/(?<currentValue>v[^/]+)/"
]
},
{
"fileMatch": [".+"],
"datasourceTemplate": "github-tags",
"matchStrings": [
"https://github\\.com/(?<depName>[^/]+/[^/]+)/releases/download/(?<currentValue>v[^/]+)/"
]
},
{
"fileMatch": [".+"],
"matchStrings": [
"# renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\s.*_?(version|VERSION)(:|=) ?(?<currentValue>.*)\\s"
],
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment