From 12826023d4999acdc0c88ec6b3103a9b24259a67 Mon Sep 17 00:00:00 2001 From: MuneebAijaz Date: Thu, 7 Nov 2024 21:33:22 +0500 Subject: [PATCH] add PR validation for helm chart --- .github/workflows/pull_request.yaml | 71 +++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 10cf41a..a489ee5 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -47,6 +47,8 @@ jobs: # Setting up helm binary - name: Set up Helm uses: azure/setup-helm@v4 + with: + version: v3.11.3 - name: Helm chart unit tests uses: d3adb5/helm-unittest-action@v2 @@ -160,3 +162,72 @@ jobs: org.opencontainers.image.source=${{ github.event.repository.clone_url }} org.opencontainers.image.created=${{ steps.prep.outputs.created }} org.opencontainers.image.revision=${{ github.sha }} + + - name: Check if Helm validation is needs to run + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + chart: + - 'deployments/kubernetes/chart/reloader/**' + + outputs: + helm_chart_changed: ${{ steps.filter.outputs.chart }} + + helm-validation: + permissions: + contents: read + + runs-on: ubuntu-latest + name: Helm Chart Validation + needs: + - build + + if: ${{ needs.build.outputs.helm_chart_changed }} == "true" + steps: + + - name: Check out code + uses: actions/checkout@v4 + with: + ref: ${{github.event.pull_request.head.sha}} + fetch-depth: 0 + + # Setting up helm binary + - name: Set up Helm + uses: azure/setup-helm@v4 + with: + version: v3.11.3 + + - name: Helm chart unit tests + uses: d3adb5/helm-unittest-action@v2 + with: + charts: deployments/kubernetes/chart/reloader + + - name: Add Stakater Helm Repo + run: | + helm repo add stakater https://stakater.github.io/stakater-charts + + - name: Get version for chart from helm repo + id: chart_eval + run: | + current_chart_version=$(helm search repo stakater/reloader | tail -n 1 | awk '{print $2}') + echo "CURRENT_CHART_VERSION=$(echo ${current_chart_version})" >> $GITHUB_OUTPUT + + - name: Get Updated Chart version from Chart.yaml + uses: mikefarah/yq@master + id: new_chart_version + with: + cmd: yq e '.version' deployments/kubernetes/chart/reloader/Chart.yaml + + - name: Check Version + uses: aleoyakas/check-semver-increased-action@v1 + id: check-version + with: + current-version: ${{ steps.new_chart_version.outputs.result }} + previous-version: ${{ steps.chart_eval.outputs.CURRENT_CHART_VERSION }} + + - name: Fail if Helm Chart version isnt updated + if: steps.check-version.outputs.is-version-increased != 'true' + run: | + echo "Helm Chart Version wasnt updated" + exit 1