Skip to content

Commit

Permalink
feat(github): Use renovate to create PRs when upstream releases (#2358)
Browse files Browse the repository at this point in the history
* feat(github): Use renovate to create PRs when upstream releases

Signed-off-by: Tim Collins <tim@thecollins.team>

* add write permissions

Signed-off-by: Tim Collins <tim@thecollins.team>

* remove the 'v' in the chart version

Signed-off-by: Tim Collins <tim@thecollins.team>

* switch to digests for actions

Signed-off-by: Tim Collins <tim@thecollins.team>

---------

Signed-off-by: Tim Collins <tim@thecollins.team>
  • Loading branch information
tico24 authored Dec 7, 2023
1 parent 690e83b commit d0e0ce7
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/chart-version-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## Used on Renovate PRs to bump the chart version and add a changelog entry
## Reference: https://github.com/stefanzweifel/git-auto-commit-action
## Reference: https://github.com/marketplace/actions/changed-files
name: 'Chart Version Bump and Changelog'

on:
pull_request:
types:
- labeled

permissions:
contents: write

jobs:
helm-bumper:
if: ${{ (contains(github.event.pull_request.labels.*.name, 'renovate')) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@https://github.com/tj-actions/changed-files/commit/1c938490c880156b746568a518594309cfb3f66b # v40.2.1
with:
files: charts/{argo-workflows,argo-cd,argo-events,argo-rollouts,argocd-image-updater}/Chart.yaml
- name: "Bump Version and Changelog"
run: |
chartName="$(echo \"${{ steps.changed-files.outputs.all_changed_files }}\" | cut -d '/' -f2)"
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=$(expr $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: |" >> ${parentDir}/Chart.yaml
echo " - kind: changed" >> ${parentDir}/Chart.yaml
echo " description: Bump ${chartName} to ${appVersion}" >> ${parentDir}/Chart.yaml
cat ${parentDir}/Chart.yaml
- name: "Commit and push changes"
uses: stefanzweifel/git-auto-commit-action@8756aa072ef5b4a080af5dc8fef36c5d586e521d # v5.0.0
with:
commit_options: '--signoff'
91 changes: 91 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"kubernetes": {
"fileMatch": ["\\.yaml$", "\\.yml$"]
},
"extends": [
"config:base",
"docker:enableMajor"
],
"labels": ["renovate"],
"includePaths": [
"**/charts/argo-workflows/Chart.yaml",
"**/charts/argo-cd/Chart.yaml",
"**/charts/argo-events/Chart.yaml",
"**/charts/argo-rollouts/Chart.yaml",
"**/charts/argocd-image-updater/Chart.yaml"
],
"regexManagers": [
{
"fileMatch": ["charts/argo-workflows/Chart.yaml$"],
"matchStrings": [
"\\sappVersion: (?<currentValue>.*)\\s"
],
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}",
"depNameTemplate": "argoproj/argo-workflows",
"datasourceTemplate": "github-releases"
},
{
"fileMatch": ["charts/argo-cd/Chart.yaml$"],
"matchStrings": [
"\\sappVersion: (?<currentValue>.*)\\s"
],
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}",
"depNameTemplate": "argoproj/argo-cd",
"datasourceTemplate": "github-releases"
},
{
"fileMatch": ["charts/argo-events/Chart.yaml$"],
"matchStrings": [
"\\sappVersion: (?<currentValue>.*)\\s"
],
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}",
"depNameTemplate": "argoproj/argo-events",
"datasourceTemplate": "github-releases"
},
{
"fileMatch": ["charts/argo-rollouts/Chart.yaml$"],
"matchStrings": [
"\\sappVersion: (?<currentValue>.*)\\s"
],
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}",
"depNameTemplate": "argoproj/argo-rollouts",
"datasourceTemplate": "github-releases"
},
{
"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"
}
],
"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-labs/argocd-image-updater"],
"commitMessagePrefix": "chore(argocd-image-updater):"
},
{
"matchPackagePatterns": ["redis-ha"],
"enabled": false
}
]
}

0 comments on commit d0e0ce7

Please sign in to comment.