Skip to content

Commit

Permalink
ci: [KDL6-66] configure updatecli.io on deps
Browse files Browse the repository at this point in the history
  • Loading branch information
ialejandro committed Nov 18, 2024
1 parent 4f111b1 commit 4f81e0d
Show file tree
Hide file tree
Showing 8 changed files with 340 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/ct.yaml → .github/ct.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# See https://github.com/helm/chart-testing#configuration
chart-dirs: charts
check-version-increment: true
check-version-increment: false
debug: false
remote: origin
target-branch: main
Expand Down
17 changes: 17 additions & 0 deletions .github/updatecli/helm-kdl-server-appversion.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
sources:
kdl-server:
kind: dockerimage
spec:
image: konstellation/kdl-server
architecture: linux/amd64
versionFilter:
kind: semver
conditions: {}
targets:
kdl-server:
name: bump chart appversion
kind: yaml
spec:
file: charts/kdl-server/Chart.yaml
key: $.appVersion
sourceid: kdl-server
83 changes: 83 additions & 0 deletions .github/updatecli/helm-kdl-server-dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
sources:
konstellation-base:
kind: helmchart
spec:
url: https://charts.konstellation.io
name: konstellation-base
versionFilter:
kind: semver
pattern: '*' # replace with CI/CD updatecli
sourceid: konstellation-base
minio:
kind: helmchart
spec:
url: https://charts.bitnami.com/bitnami
name: minio
versionFilter:
kind: semver
pattern: '*' # replace with CI/CD updatecli
sourceid: minio
mongodb:
kind: helmchart
spec:
url: https://charts.bitnami.com/bitnami
name: mongodb
versionFilter:
kind: semver
pattern: '*' # replace with CI/CD updatecli
sourceid: mongodb
oauth2-proxy:
kind: helmchart
spec:
url: https://oauth2-proxy.github.io/manifests
name: oauth2-proxy
versionFilter:
kind: semver
pattern: '*' # replace with CI/CD updatecli
sourceid: oauth2-proxy
postgresql:
kind: helmchart
spec:
url: https://charts.bitnami.com/bitnami
name: postgresql
versionFilter:
kind: semver
pattern: '*' # replace with CI/CD updatecli
sourceid: postgresql
conditions: {}
targets:
konstellation-base:
name: bump chart dependencies
kind: yaml
spec:
file: charts/kdl-server/Chart.yaml
key: $.dependencies[0].version
sourceid: konstellation-base
minio:
name: bump chart dependencies
kind: yaml
spec:
file: charts/kdl-server/Chart.yaml
key: $.dependencies[1].version
sourceid: minio
mongodb:
name: bump chart dependencies
kind: yaml
spec:
file: charts/kdl-server/Chart.yaml
key: $.dependencies[2].version
sourceid: mongodb
oauth2-proxy:
name: bump chart dependencies
kind: yaml
spec:
file: charts/kdl-server/Chart.yaml
key: $.dependencies[3].version
sourceid: oauth2-proxy
postgresql:
name: bump chart dependencies
kind: yaml
spec:
file: charts/kdl-server/Chart.yaml
key: $.dependencies[4].version
sourceid: postgresql
81 changes: 81 additions & 0 deletions .github/workflows/helm-check-kdl-server-major-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: "[Helm] Check KDL Server major dependencies releases"

on:
workflow_dispatch:
schedule:
- cron: '0 0 1 * *' # first day of month

jobs:
check-and-update-major-dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Prepare updatecli configuration
id: dependencies
run: |
# get name dependencies
dependencies=($(yq eval -o=json '.dependencies[] | .name' charts/kdl-server/Chart.yaml | xargs))
# replace version
for dependency in "${dependencies[@]}"; do
yq eval -i ".sources.${dependency}.spec.versionFilter.pattern = \"*\"" .github/updatecli/helm-kdl-server-dependencies.yaml
done
- name: Install updatecli
uses: updatecli/updatecli-action@v2

- name: Update dependencies
run: |
updatecli apply --config .github/updatecli/helm-kdl-server-dependencies.yaml --commit=false 2>&1 | tee > $GITHUB_WORKSPACE/major-output.log
# show PR body
cat major-output.log
shell: bash
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Update README.md Helm Chart
uses: losisin/helm-docs-github-action@v1
with:
chart-search-root: charts/kdl-server

- name: Get current date
id: date
run: |
echo "date=$(date -I)" >> $GITHUB_OUTPUT
- name: Create PR with changes (dry-run)
uses: peter-evans/create-pull-request@v7
if: github.event_name == 'workflow_dispatch'
with:
add-paths: charts/kdl-server
token: ${{ secrets.PAT }}
commit-message: "fix: update major dependencies version"
signoff: false
branch: chore/upgrade-kdl-server-major-dependencies-${{ steps.date.outputs.date }}
delete-branch: true
title: '[kdl-server] upgrade major dependencies (${{ steps.date.outputs.date }})'
body-path: major-output.log
draft: true
labels: |
auto-pr-bump-version
- name: Create PR with changes
uses: peter-evans/create-pull-request@v7
if: github.event_name == 'schedule'
with:
add-paths: charts/kdl-server
token: ${{ secrets.PAT }}
commit-message: "fix: update major dependencies version"
signoff: false
branch: chore/upgrade-kdl-server-major-dependencies-${{ steps.date.outputs.date }}
delete-branch: true
title: '[kdl-server] upgrade major dependencies (${{ steps.date.outputs.date }})'
body-path: major-output.log
labels: |
auto-pr-bump-version
79 changes: 79 additions & 0 deletions .github/workflows/helm-check-kdl-server-minor-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: "[Helm] Check KDL Server minor dependencies releases"

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' # every monday

jobs:
check-and-update-minor-dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Prepare updatecli configuration
id: dependencies
run: |
# get name dependencies
dependencies=($(yq eval -o=json '.dependencies[] | .name' charts/kdl-server/Chart.yaml | xargs))
# replace version
for dependency in "${dependencies[@]}"; do
version="~$(yq eval -r ".dependencies[] | select(.name == \"${dependency}\") | .version" charts/kdl-server/Chart.yaml | cut -d'.' -f1)"
yq eval -i ".sources.${dependency}.spec.versionFilter.pattern = \"${version}\"" .github/updatecli/helm-kdl-server-dependencies.yaml
done
- name: Install updatecli
uses: updatecli/updatecli-action@v2

- name: Update dependencies
run: |
updatecli apply --config .github/updatecli/helm-kdl-server-dependencies.yaml --commit=false 2>&1 | tee > $GITHUB_WORKSPACE/minor-output.log
shell: bash
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Update README.md Helm Chart
uses: losisin/helm-docs-github-action@v1
with:
chart-search-root: charts/kdl-server

- name: Get current date
id: date
run: |
echo "date=$(date -I)" >> $GITHUB_OUTPUT
- name: Create PR with changes (dry-run)
uses: peter-evans/create-pull-request@v7
if: github.event_name == 'workflow_dispatch'
with:
add-paths: charts/kdl-server
token: ${{ secrets.PAT }}
commit-message: "fix: update minor dependencies version"
signoff: false
branch: chore/upgrade-kdl-server-minor-dependencies-${{ steps.date.outputs.date }}
delete-branch: true
title: '[kdl-server] upgrade minor dependencies (${{ steps.date.outputs.date }})'
body-path: minor-output.log
draft: true
labels: |
auto-pr-bump-version
- name: Create PR with changes
uses: peter-evans/create-pull-request@v7
if: github.event_name == 'schedule'
with:
add-paths: charts/kdl-server
token: ${{ secrets.PAT }}
commit-message: "fix: update minor dependencies version"
signoff: false
branch: chore/upgrade-kdl-server-minor-dependencies-${{ steps.date.outputs.date }}
delete-branch: true
title: '[kdl-server] upgrade minor dependencies (${{ steps.date.outputs.date }})'
body-path: minor-output.log
labels: |
auto-pr-bump-version
67 changes: 67 additions & 0 deletions .github/workflows/helm-check-kdl-server-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: "[Helm] Check KDL Server new releases"

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # every day

jobs:
check-and-update-kdl-server:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Get current release
id: current_release
run: |
current_release=$(grep appVersion charts/kdl-server/Chart.yaml | awk '{ print $2 }')
echo "current_release=$current_release" >> $GITHUB_OUTPUT
- name: Install updatecli
uses: updatecli/updatecli-action@v2

- name: Update dependencies
run: |
updatecli apply --config .github/updatecli/helm-kdl-server-appversion.yaml --commit=false
- name: Get latest release
id: latest_release
run: |
latest_release=$(grep appVersion charts/kdl-server/Chart.yaml | awk '{ print $2 }')
echo "latest_release=$latest_release" >> $GITHUB_OUTPUT
- name: Check if release changed
id: check_changes
run: |
if [ ${{ steps.latest_release.outputs.latest_release }} != ${{ steps.current_release.outputs.current_release }} ]; then
echo "release_changed=true" >> $GITHUB_OUTPUT
fi
- name: Update README.md Helm Chart
if: steps.check_changes.outputs.release_changed == 'true'
uses: losisin/helm-docs-github-action@v1
with:
chart-search-root: charts/kdl-server

- name: Create PR with changes
if: steps.check_changes.outputs.release_changed == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.PAT }}
commit-message: "fix: update KDL Server version to ${{ steps.latest_release.outputs.latest_release }}"
signoff: false
branch: chore/upgrade-kdl-server-appversion-${{ steps.latest_release.outputs.latest_release }}
delete-branch: true
title: '[kdl-server] new release: ${{ steps.latest_release.outputs.latest_release }}'
body: |
KDL Server version:
- :information_source: Current: `${{ steps.current_release.outputs.current_release }}`
- :up: Upgrade: `${{ steps.latest_release.outputs.latest_release }}`
Changelog: https://github.com/konstellation-io/kdl-server/releases/tag/${{ steps.latest_release.outputs.latest_release }}
labels: |
auto-pr-bump-version
15 changes: 11 additions & 4 deletions .github/workflows/helm-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

# default install latest (stable)
- name: Set up Helm
Expand All @@ -30,23 +31,29 @@ jobs:
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --config .github/ct.yaml)
changed=$(ct list-changed --config .github/ct.yml)
if [[ -n "${changed}" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Add repositories
run: |
for dir in $(ls -d charts/*/); do
helm dependency list $dir 2> /dev/null | grep -v 'oci://' | tail +2 | head -n -1 | awk '{ print "helm repo add " $1 " " $3 }' | while read cmd; do $cmd; done
done
- name: Run ct lint
if: steps.list-changed.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
run: ct lint --config .github/ct.yaml --lint-conf .github/helmlintconf.yaml
run: ct lint --config .github/ct.yml --lint-conf .github/helmlintconf.yaml

- name: Create kind cluster
if: steps.list-changed.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
uses: helm/kind-action@v1

- name: Run ct install
if: steps.list-changed.outputs.changed == 'true'
run: ct install --config .github/ct.yaml --helm-extra-args '--timeout 900s --debug'
run: ct install --config .github/ct.yml --helm-extra-args '--timeout 900s --debug'

- name: (workflow_dispatch) Run ct install
if: github.event_name == 'workflow_dispatch'
run: ct install --config .github/ct.yaml --helm-extra-args '--timeout 900s --debug' --all
run: ct install --config .github/ct.yml --helm-extra-args '--timeout 900s --debug' --all
1 change: 1 addition & 0 deletions .github/workflows/helm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Configure Git
run: |
Expand Down

0 comments on commit 4f81e0d

Please sign in to comment.