From d4715ceb22d6515344dbc68c9e0d83817f13a90f Mon Sep 17 00:00:00 2001 From: Alex Lanz Date: Thu, 21 Aug 2025 14:19:25 +0200 Subject: [PATCH 1/2] add Grafana dashboards and alerts --- helm-deploy/action.yml | 52 +++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/helm-deploy/action.yml b/helm-deploy/action.yml index 6beb1cb..998ac74 100644 --- a/helm-deploy/action.yml +++ b/helm-deploy/action.yml @@ -26,18 +26,24 @@ inputs: namespace: description: "The namespace in which to deploy the Helm chart and application" required: true - values-file: - description: "Path to the Helm values file" - required: true image-tag: description: "Tag of the container image" default: "latest" - timeout: - description: "Timeout for the Helm command" - default: "5m" working-directory: description: "The working directory" default: "." + values-file: + description: "Path to the Helm values file" + required: true + grafana-dashboards-folder: + description: "Folder containing Grafana dashboards" + default: "dashboards" + grafana-alerts-folder: + description: "Folder containing Grafana alerts" + default: "alerts" + timeout: + description: "Timeout for the Helm command" + default: "5m" runs: using: "composite" @@ -69,6 +75,35 @@ runs: yq -i '.appVersion = "${{ github.sha }}" | .appVersion style="double"' \ ${{ inputs.helm-package }}/Chart.yaml + - name: Collect Grafana dashboards and alerts + id: grafana-files + shell: bash + working-directory: ${{ inputs.working-directory }} + run: | + SET_FILE_ARGS="" + + if [[ -d "${{ inputs.grafana-dashboards-folder }}" ]] && [[ "$(ls -A "${{ inputs.grafana-dashboards-folder }}")" ]]; then + i=0 + for f in "${{ inputs.grafana-dashboards-folder }}"/*; do + if [[ -f "$f" ]]; then + SET_FILE_ARGS+=" --set-file grafana.dashboards[$i]=$f" + ((i++)) + fi + done + fi + + if [[ -d "${{ inputs.grafana-alerts-folder }}" ]] && [[ "$(ls -A "${{ inputs.grafana-alerts-folder }}")" ]]; then + i=0 + for f in "${{ inputs.grafana-alerts-folder }}"/*; do + if [[ -f "$f" ]]; then + SET_FILE_ARGS+=" --set-file grafana.alerts[$i]=$f" + ((i++)) + fi + done + fi + + echo "set-file-args=$SET_FILE_ARGS" >> $GITHUB_OUTPUT + - name: Deploy Helm chart shell: bash working-directory: ${{ inputs.working-directory }} @@ -76,8 +111,9 @@ runs: HELM_DRIVER: configmaps run: | helm upgrade --wait --install ${{ inputs.release-name }} ./${{ inputs.helm-package }} \ - --namespace ${{ inputs.namespace }} \ --history-max 10 \ - --values ${{ inputs.values-file }} \ --atomic --timeout ${{ inputs.timeout }} \ --set image.tag=${{ inputs.image-tag }} + --namespace ${{ inputs.namespace }} \ + --values ${{ inputs.values-file }} \ + ${{ steps.grafana-files.outputs.set-file-args }} From b32f595bd70c5e160782a17cd9c03c406d468179 Mon Sep 17 00:00:00 2001 From: Alex Lanz Date: Thu, 21 Aug 2025 16:21:50 +0200 Subject: [PATCH 2/2] Update helm-deploy/action.yml Co-authored-by: Simon Planinschek --- helm-deploy/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-deploy/action.yml b/helm-deploy/action.yml index 998ac74..88b0ff6 100644 --- a/helm-deploy/action.yml +++ b/helm-deploy/action.yml @@ -113,7 +113,7 @@ runs: helm upgrade --wait --install ${{ inputs.release-name }} ./${{ inputs.helm-package }} \ --history-max 10 \ --atomic --timeout ${{ inputs.timeout }} \ - --set image.tag=${{ inputs.image-tag }} + --set image.tag=${{ inputs.image-tag }} \ --namespace ${{ inputs.namespace }} \ --values ${{ inputs.values-file }} \ ${{ steps.grafana-files.outputs.set-file-args }}