Skip to content

Commit

Permalink
chore: Migrate to renovate GH action
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Maurer <mkilchhofer@users.noreply.github.com>
  • Loading branch information
mkilchhofer committed Feb 29, 2024
1 parent 4882466 commit bb5effd
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 75 deletions.
7 changes: 7 additions & 0 deletions .github/configs/renovate-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
platform: 'github',
gitAuthor: 'renovate[bot] <renovate[bot]@users.noreply.github.com>',
autodiscover: false,
allowPostUpgradeCommandTemplating: true,
allowedPostUpgradeCommands: [".*"],
};
57 changes: 0 additions & 57 deletions .github/workflows/chart-version-bump.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/renovate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Renovate
on:
# The "*" (#42, asterisk) character has special semantics in YAML, so this
# string has to be quoted.
schedule:
- cron: '0 * * * *'
# Manual trigger is also possible
workflow_dispatch: {}

permissions:
contents: read

jobs:
renovate:
runs-on: ubuntu-latest
steps:
- name: Get token
uses: actions/create-github-app-token@f4c6bf6752984b3a29fcc135a5e70eb792c40c6b # v1.8.0
id: get_token
with:
app-id: ${{ vars.RENOVATE_APP_ID }}
private-key: ${{ secrets.RENOVATE_APP_PRIVATE_KEY }}

- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Self-hosted Renovate
uses: renovatebot/github-action@2d90417499f45ff78a09586f7b9874b19817dba3 # v40.1.0
with:
configurationFile: .github/configs/renovate-config.js
# renovate: datasource=docker depName=ghcr.io/renovatebot/renovate
renovate-version: 37.192.1
token: '${{ steps.get_token.outputs.token }}'
env:
LOG_LEVEL: 'debug'
RENOVATE_REPOSITORIES: '${{ github.repository }}'
48 changes: 30 additions & 18 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"fileMatch": ["\\.yaml$", "\\.yml$"]
},
"extends": [
"config:base",
"config:recommended",
"docker:enableMajor"
],
"labels": ["renovate"],
Expand All @@ -13,10 +13,12 @@
"**/charts/argo-cd/Chart.yaml",
"**/charts/argo-events/Chart.yaml",
"**/charts/argo-rollouts/Chart.yaml",
"**/charts/argocd-image-updater/Chart.yaml"
"**/charts/argocd-image-updater/Chart.yaml",
"**/.github/workflows/renovate.yaml"
],
"regexManagers": [
"customManagers": [
{
"customType": "regex",
"fileMatch": ["charts/argo-workflows/Chart.yaml$"],
"matchStrings": [
"\\sappVersion: (?<currentValue>.*)\\s"
Expand All @@ -26,6 +28,7 @@
"datasourceTemplate": "github-releases"
},
{
"customType": "regex",
"fileMatch": ["charts/argo-cd/Chart.yaml$"],
"matchStrings": [
"\\sappVersion: (?<currentValue>.*)\\s"
Expand All @@ -35,6 +38,7 @@
"datasourceTemplate": "github-releases"
},
{
"customType": "regex",
"fileMatch": ["charts/argo-events/Chart.yaml$"],
"matchStrings": [
"\\sappVersion: (?<currentValue>.*)\\s"
Expand All @@ -44,6 +48,7 @@
"datasourceTemplate": "github-releases"
},
{
"customType": "regex",
"fileMatch": ["charts/argo-rollouts/Chart.yaml$"],
"matchStrings": [
"\\sappVersion: (?<currentValue>.*)\\s"
Expand All @@ -53,35 +58,42 @@
"datasourceTemplate": "github-releases"
},
{
"customType": "regex",
"fileMatch": ["charts/argocd-image-updater/Chart.yaml$"],
"matchStrings": [
"\\sappVersion: (?<currentValue>.*)\\s"
],
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}",
"depNameTemplate": "argoproj-labs/argocd-image-updater",
"datasourceTemplate": "github-releases"
},
{
"customType": "regex",
"fileMatch": ["^\\.github/workflows/[^/]+\\.ya?ml$"],
"matchStrings": [
"# renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)\\s+.+version: (?<currentValue>.*)"
]
}
],
"packageRules": [
{
"matchPackagePatterns": ["argoproj/argo-workflows"],
"commitMessagePrefix": "chore(argo-workflows):"
},
{
"matchPackagePatterns": ["argoproj/argo-cd"],
"commitMessagePrefix": "chore(argo-cd):"
},
{
"matchPackagePatterns": ["argoproj/argo-events"],
"commitMessagePrefix": "chore(argo-events):"
},
{
"matchPackagePatterns": ["argoproj/argo-rollouts"],
"commitMessagePrefix": "chore(argo-rollouts):"
"matchPackagePatterns": [
"argoproj/argo-workflows",
"argoproj/argo-cd",
"argoproj/argo-events",
"argoproj/argo-rollouts"
],
"commitMessagePrefix": "chore({{{replace 'argoproj/' '' depName}}}):",
"postUpgradeTasks": {
"commands": ["./scripts/renovate-bump-version.sh {{depName}}"]
}
},
{
"matchPackagePatterns": ["argoproj-labs/argocd-image-updater"],
"commitMessagePrefix": "chore(argocd-image-updater):"
"commitMessagePrefix": "chore({{{replace 'argoproj-labs/' '' depName}}}):",
"postUpgradeTasks": {
"commands": ["./scripts/renovate-bump-version.sh {{depName}}"]
}
},
{
"matchPackagePatterns": ["redis-ha"],
Expand Down
31 changes: 31 additions & 0 deletions scripts/renovate-bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
depName="${1}"
if [ -z "${depName}" ]; then
echo "Missing argument 'depName'" >&2
echo "Example usage: $0 argoproj/argo-cd" >&2
exit 1
fi

chartName=$(echo "$depName" | sed -e "s+^argoproj/++" -e "s+^argoproj-labs/++")
echo "Changed chart name is: $chartName"
echo "----------------------------------------"

parentDir="charts/${chartName}"

# Bump the chart version by one patch version
version=$(grep '^version:' "${parentDir}/Chart.yaml" | awk '{print $2}')
major=$(echo "${version}" | cut -d. -f1)
minor=$(echo "${version}" | cut -d. -f2)
patch=$(echo "${version}" | cut -d. -f3)
patch=$((patch + 1))
sed -i "s/^version:.*/version: ${major}.${minor}.${patch}/g" "${parentDir}/Chart.yaml"

# Add a changelog entry
appVersion=$(grep '^appVersion:' "${parentDir}/Chart.yaml" | awk '{print $2}')
sed -i -e '/^ artifacthub.io\/changes: |/,$ d' "${parentDir}/Chart.yaml"
{
echo " artifacthub.io/changes: |"
echo " - kind: changed"
echo " description: Bump ${chartName} to ${appVersion}"
} >> "${parentDir}/Chart.yaml"
cat "${parentDir}/Chart.yaml"

0 comments on commit bb5effd

Please sign in to comment.