Skip to content

Commit

Permalink
ci: add centralized workflow to upgrade charts dependencies on modules (
Browse files Browse the repository at this point in the history
#1009)

* ci: add description to terraform-docs workflow input

* ci: add first draft of the centralized workflow

* ci: complete the workflow for automatic upgrade of Helm deps
  • Loading branch information
lentidas authored Jul 4, 2023
1 parent 0bd0dc6 commit a8441a5
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 1 deletion.
112 changes: 112 additions & 0 deletions .github/workflows/modules-chart-upgrade.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
# GitHub Actions workflow to upgrade the Helm chart dependencies on our modules.
#
# IMPORTANT: This workflow is called by other workflows in our DevOps Stack repositories and it is centralized here in
# order to be easily maintained across modules. Because of this, please make sure you're not introducing any breaking
# changes when modifying this workflow.

name: "modules-chart-upgrade"

on:
workflow_call:
inputs:
upgrade-strategy:
description: "Upgrade strategy to use. Valid values are 'major', 'minor' or 'patch'."
type: string
required: true
excluded-dependencies:
description: "Comma-separated list of dependencies to exclude from upgrade (i.e. 'dependency1,dependency2,dependency3')."
type: string
required: false
default: ""
dry-run:
description: "Whether to run the upgrade in dry-run mode or not."
type: boolean
required: false
default: false

jobs:
list-charts:
runs-on: ubuntu-latest
outputs:
charts: ${{ steps.find-charts.outputs.charts }}

steps:
- name: "Check out the repository"
uses: actions/checkout@v3

- name: "List charts in the ./charts folder"
id: find-charts
run: |
echo "::set-output name=charts::$(find charts -name 'Chart.yaml' -exec dirname {} \; | sed 's|^\./||' | sort -u)"
chart-upgrade:
runs-on: ubuntu-latest

# Require the previous step to be completed before running this job
needs: list-charts

strategy:
matrix:
chart-name: ${{ fromJson(needs.list-charts.outputs.charts) }}

# Define global settings for both PR steps
env:
committer: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
branch: "chart-autoupgrade-${{ inputs.upgrade-strategy }}-${{ matrix.chart-name }}"
labels: "chart-autoupgrade-${{ inputs.upgrade-strategy }}"

steps:
- name: "Check out the repository"
uses: actions/checkout@v3

- name: "Upgrade Helm chart dependencies"
id: deps-upgrade
uses: camptocamp/helm-dependency-upgrade-action@v0
with:
chart-path: "charts/${{ matrix.chart-name }}"
excluded-dependencies: ${{ inputs.excluded-dependencies }}}
upgrade-strategy: "${{ inputs.upgrade-strategy }}"
dry-run: "${{ inputs.dry-run }}"

# TODO Add step that updates the chart version on the README.adoc using the new version from the Chart.yaml file. Maybe that step should be outside of this centralized workflow...

- name: "Create Pull Request for a minor/patch upgrade"
if: ${{ inputs.upgrade-strategy != 'major' }} && ${{ steps.deps-upgrade.outputs.chart-upgraded == 'true' }} && ${{ inputs.dry-run == 'false' }}
uses: peter-evans/create-pull-request@v3
env:
pr-title: "chore(chart): ${{ inputs.upgrade-strategy }} upgrade of dependencies on ${{ matrix.chart-name }} chart"
with:
commit-message: ${{ env.pr-title }}
committer: ${{ env.committer }}}
branch: ${{ env.branch }}
title: ${{ env.pr-title }}
labels: "${{ env.labels }}"
body: |
:robot: I have update the chart *beep* *boop*
---
## Description of the changes
This PR upgrades the dependencies of the **${{ matrix.chart-name }}** Helm chart using a **${{ inputs.upgrade-strategy }}** upgrade strategy.
- name: "Create Pull Request for a major upgrade"
if: ${{ inputs.upgrade-strategy == 'major' }} && ${{ steps.deps-upgrade.outputs.chart-upgraded == 'true' }} && ${{ inputs.dry-run == 'false' }}
uses: peter-evans/create-pull-request@v3
env:
pr-title: "chore!(chart): major upgrade of dependencies on ${{ matrix.chart-name }} chart"
with:
commit-message: ${{ env.pr-title }}
committer: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
branch: "helm-${{ inputs.upgrade-strategy }}-autoupgrade-${{ matrix.chart-name }}"
title: ${{ env.pr-title }}
labels: "${{ env.labels }}"
body: |
:robot: I have update the chart *beep* *boop*
---
## Description of the changes
This PR upgrades the dependencies of the **${{ matrix.chart-name }}** Helm chart using a **major** upgrade strategy.
:warning: **This is a major upgrade, please take care to check the official chart changelog for breaking changes before merging.** :warning:
2 changes: 1 addition & 1 deletion .github/workflows/modules-terraform-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
workflow_call:
inputs:
variants:
# List of the variants folders as a comma-separated list inside a string (i.e. "eks,aks,sks").
description: "List of the variants folders as a comma-separated list inside a string (i.e. "eks,aks,sks")."
type: string
required: false
default: ""
Expand Down

0 comments on commit a8441a5

Please sign in to comment.